[En-Nut-Discussion] Register overwriting in interrupted code

Gordian Elsinger elsinger at ise.de
Thu Jul 22 17:44:09 CEST 2004


In in the serial port implementation uartavr.c we encountered a strange
problem: in "int UartAvrInput(NUTDEVICE * dev)" there is a
NutEventWait() function; when the event is set, dev (r21:r20) and
another variable, which both have been stored in a register pair each,
are overwritten with 0.
It seems that the eventing code (interrupt driven) somewhere uses those
registers and does not restore them to their original values. Shouldn't
the interrupt code take care of the registers it uses?


Another thing is, that the following code runs in the same function
(UartAvrInput):

    NutEnterCritical();
...
            rc = NutEventWait(&dcb->dcb_rx_rdy, dcb->dcb_rtimeout);
... 
   NutExitCritical();

How can that work? Or rather: does it make sense to enter a critical
section (disabling interrupts) and then wait for interrupt driven events
(I know that this usually works, but how)?

Cheers,
Gordian




More information about the En-Nut-Discussion mailing list