Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

alt_nticks(); Correct method to measure time

Hi,

What is the accurate way to measure time in Nios II? I am implementing a co-processor using stream-like process in Nios II. For measuring time, I am using alt_nticks from <sys/alt_alarm.h>

Here is how my code works:

start_time = alt_nticks();

open_stream();

// perform read, write to the stream

// perform calculations

close_stream();

finish_time = alt_nticks();

total_time = (finish_time - start_time)/ alt_tick_per_second();

The problem is the time measured from the method above produces only 40s, whereas it takes ~10 mins to run the code.

The alt_ticks_per_second is 100, but i think it is way lower than that. It is either alt_nticks() or alt_ticks_per_second() that is not accurate.

Anyone has a better idea?
No RepliesBe the first to reply