[En-Nut-Discussion] NutGetMillis in Uart ISR

Hugo Simon hugo.simon at gmx.de
Tue Nov 6 23:08:34 CET 2007


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.

In a timer thread I read that value and compare it with the current
NutGetMillis. If the difference is more than 100ms I detect a timeout.

It mostly works, but sometimes there is a detection of a timeout, but there
is none.

Thanks Thorsten

volatile u_long RS485RcvTime;
 * serial receive isr
 char ch;
 char *RS485Buffer=(char *)RS485PacketBuffer;


 // ... receive the character ...

THREAD(RS485Receiver, arg)
 u_long timeout;

 // now wait endlessly for packets
    for (;;)

         if (timeout>100)
            // ... do some stuff with the received data


More information about the En-Nut-Discussion mailing list