Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12599 Discussions

Using timestamp in an interrupt

Honored Contributor II

Hi, i wanted to use the timestamp driver to get an approximation of the time spend in an ISR. Has anyone tried/achieved this? Should it be possible? 


I have tried it, but even if i do sequential timestamps, then i consistently get a difference of more than 260,000 counts. 

It can't possibly be taking this long to run that code. Debugger is connected for purposes of download to RAM, but debug is off. Timers and Nios II are connected to a 50MHz clk. 


The timestamp driver seems to be working fine elsewhere in the code and has an overhead < 100 counts . 


Could this be anything to do with it being in the interrupt? 

I do have other interrupts running, but even if nesting was somehow enabled, then surely the code i have used would prevent them interrupting this code?  

alt_irq_context context1 = alt_irq_disable_all(); 







timestamp(unsignedint index){//use the altera timestamp driver to get the time 

m_timestamps[index] = alt_timestamp(); 

0 Kudos
1 Reply
Honored Contributor II

Problem seems to be solved. The code wasn't properly protecting m_timestamps from race conditions when I was reading them out. Now i am doing this, the counts value seems a lot more reasonable. Thanks Altera for your help. 


0 Kudos