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

Altera_Forum
Honored Contributor II
1,409 Views

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(start_of_tick);  

TIMESTAMP(end_of_tick);  

alt_irq_enable_all(context1); 

 

 

void 

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

m_timestamps[index] = alt_timestamp(); 

0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
641 Views

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. 

 

Mel
0 Kudos
Reply