Forum Discussion
Hi,
Can you tell me more about the interval timer part? Where is it are you adding in Quartus or to you Nios II C code?
Maybe you could share the full "internal timer design" here so I could see the full error and try to see how I could help on it.
Hello,
Sorry for the confusion, the "interval timer" was renamed by me as a "timestamp_timer" in the design, you may find it from the attached .sopcinfo file, so it was connected as a peripheral in Nios II. At the moment, BSP project has been successfully generated by typing "nios2-bsp-generate-files --bsp-dir . --settings settings.bsp" at the relevant directory via Nios II command shell, but BSP still cannot be automatically generated by clicking "generate BSP" at the sub-menu of "Nios II" in Eclipse.
Hence, generate BSP could be partially resolved at present, as the programme in C can be downlaoded and executed in Nios II. However, some new issues were encountered recently. As I mentioned that I was trying to measure the code running time by using an interval timer (i.e., "timestamp_timer" in my design), but it seems that my programme "froze"/stucked at "alt_timestamp_start()" when executing the code. Please see part of my test code below:
______________________________________________________
#include "system.h"
#include "sys/alt_timestamp.h"
#include "alt_types.h"
int main()
{
alt_u32 t0, t1;
alt_timestamp_start();
t0 = alt_timestamp();
usleep(10000000);
t1 = alt_timestamp();
printf("time stamp t0 = %ld \n", t0);
printf("time stamp t1 = %ld \n", t1);
printf("time stamps (t1-t0) = %ld \n", (t1-t0));
printf("\n");
return 0;
}
______________________________________________________
In this method, I also enabled timestamp_timer in BSP editor, please see the screen shot below:
Having realised time stamp method may not work properly, I tried another method to measure the code running time, which is almost the same as this one: https://community.intel.com/t5/Nios-V-II-Embedded-Design-Suite/How-to-calculate-the-time-for-running-the-code-in-Nios-II-and/m-p/1430160 (BTW, the peripheral "interval timer" (i.e., timestamp_timer) connection in my design is exactly the same as the one mentioned in this link). Since both of the methods have to utilise the "interval timer". Hence, I changed my test code as follows:
______________________________________________________
#include "stdio.h"
#include "unistd.h"
#include "time.h"
#include <math.h>
int main()
{
clock_t t;
t = clock();
usleep(10000000);
t = clock() - t;
printf("It took me %ld clocks. \n", t);
return 0;
}
______________________________________________________
Further, in this second method, I enabled sys_clk_timer in BSP editor, since the programme is counting system clock cycles...
However, the second method is returning 0 clocks from printf(), in other words, the value of "t" doesn't change...
There should be something wrong in the design settings (perhaps BSP settings) or something wrong about the timestamp_timer connections. Could you please help to check it? Thank you very much in advance.