[En-Nut-Discussion] NutGetMillis in Uart ISR

Harald Kipp harald.kipp at egnite.de
Wed Nov 7 15:48:32 CET 2007


Hugo Simon schrieb:
> May I use the NutGetMillis() function in the Uart interrupt service routine?
> I want to use it to detect a timeout. Therefore I have defined a global
> variable RcvTime which is set to NutGetMillis everytime the uart receive ISR
> is called.
>   
Your routine looks correct to me. I'd suggest not to call any other API 
than NutEventPostFromIrq() while servicing an interrupt. I may work now 
but may not with a new release.

Some time ago someone decided to make the system tick counter nut_ticks 
a global variable. Thus, you can access it directly in your interrupt 
routine, which is much faster.

Btw. if you access nut_ticks in normal mode (not in interrupt context), 
do use a critical section, e.g.

    NutEnterCritical();
    myticks = nut_ticks;
    NutExitCritical();


Harald




More information about the En-Nut-Discussion mailing list