Altera_Forum
Honored Contributor
13 years agotimes() always returns 1 in NIOS II
Hi,
I am trying to measure the process execution time using the following code...# include <stdlib.h># include "sys/alt_stdio.h"# include <sys/alt_alarm.h># include "sys/times.h"# include "alt_types.h"# include "system.h"# include <unistd.h>
int main()
{
char buffer;
clock_t T1, T2;
//###########
T1 = times(NULL);
//my statements here
T2 = times(NULL);
//###########
gcvt(((double)T2-(double)T1) / alt_ticks_per_second(), 10, buffer);
alt_putstr(buffer);
return 0;
}
I have an Interval Timer existing and connected in my NIOS II processor and floating point custom instructions, also I have sys_clk_timer set in the BSP editor, but this code outputs NaN. If I just output T2 and T1, I always only get 1 respectively. I tried to figure out the error for hours, but cant just cant think of why it doesnt work... Hope you guys have an idea. Thx in advance. Jimmy