SCI TEI interrupt

I've written my software to follow the sequence in the RA4M1 manual, figure 28.10, and I want to use the TEI interrupt to switch off the RS485 line driver when the data has been sent.

I negate TXI and enable TEI immediately after sending the last byte to TDR.

It works perfectly, apart from one thing - it generates the TEI interrupt twice, even though I negate TEIE in the interrupt service routine.

(Running the ISR twice doesn't affect the operation of the program, but wouldn't it be tidier if if didn't?)

Parents Reply Children
  • I found the TEI interrupt handler in FSP, and checked it against mine.

    I always clear the flag

    R_ICU->IELSR[2] &= ~(1U << 16);

    at the beginning of the service routine, but FSP clears it at the end (I don't know whether that applies to every interrupt service routine in FSP or just this one.

    Obviously, the act of clearing TEIE, TIE and TE results in an undocumented TEI interrupt being generated, which is then cleared by clearing IELSR at the END of the ISR.