Altera_Forum
Honored Contributor
15 years agoalt_timestamp() question
Hi!
I am just wondering if my understanding of the alt_timestamp is totally wrong... My oszillator clock is 50MHz which i can see in the sopc builder and which has never changed. I configured a 32bit/1millisec interval timer in the sopc builder (i named it "TIMER_MSEC") for my nios ii and selected it to the timestamp timer in the BSP editor. Here are the settings:# define ALT_MODULE_CLASS_Timer_Msec altera_avalon_timer# define TIMER_MSEC_ALWAYS_RUN 1# define TIMER_MSEC_BASE 0x0# define TIMER_MSEC_COUNTER_SIZE 32# define TIMER_MSEC_FIXED_PERIOD 0# define TIMER_MSEC_FREQ 50000000u# define TIMER_MSEC_IRQ 0# define TIMER_MSEC_IRQ_INTERRUPT_CONTROLLER_ID 0# define TIMER_MSEC_LOAD_VALUE 49999ULL# define TIMER_MSEC_MULT 0.0010# define TIMER_MSEC_NAME "/dev/Timer_Msec"# define TIMER_MSEC_PERIOD 1# define TIMER_MSEC_PERIOD_UNITS "ms"# define TIMER_MSEC_RESET_OUTPUT 0# define TIMER_MSEC_SNAPSHOT 1# define TIMER_MSEC_SPAN 32# define TIMER_MSEC_TICKS_PER_SEC 1000u# define TIMER_MSEC_TIMEOUT_PULSE_OUTPUT 0# define TIMER_MSEC_TYPE "altera_avalon_timer" # define ALT_MAX_FD 4# define ALT_SYS_CLK none# define ALT_TIMESTAMP_CLK TIMER_MSEC At program start i use alt_timestamp_start() once. Afterwards i do multiple read outs of alt_timestamp(). Expected behaviour: I though the value alt_timestamp() should increase every millisec by one. That means i should reach the limits of the 32bit timer after 49 days. Observed behaviour: The value of alt_timestamp() reaches the limits of 32bit after approximately 90 seconds. Do anybody have an explanation why alt_timestamp() is so fast? Is my understanding of the interval timer totally wrong? What perhaps is the best way to implement a 32bit millisec clock in the nios (i would like to have a clock that can be accessed like this in code: t = GetMillisecClock())? Regards FredFlintstone