Hello Johan,
It is likely that the overrun error has already occurred by the time that the ISR code executes. An overrun occurs when a new character has been received by the SCI, but the previous character within the receive buffer has not yet been read, with the new data being lost.
The RDRF flag does not actually clear until both the SCIS1 register has been read, followed by the SCID register.
One possible cause of the overrun is that the commencement of the SCI receive ISR is delayed by the execution of another ISR, possibly one of the TPM interrupts, which have higher priority in a pending interrupt situation. There may be a number of reasons for this -
- The SCI baud rate is too high for the bus clock frequency in use.
The execution cycles of the SCI receive ISR is too long. Any lengthy manipulation of the received data should be done from outside the ISR.
The execution cycles of one or more of the other enabled interrupts is too long.
To ensure that overrun does not occur, 10 times the baud period needs to be greater than the execution cycles of the SCI receive ISR itself, plus the worst case execution cycles of the longest "other" ISR. Assuming this is the problem, it demonstrates the need to always keep all ISR code as short as possible.
The state of the OR flag, as well as the RDRF flag, may be tested within the ISR. Whenever an overrun error is detected, you will probably need to flag that an error response needs to be returned, so the the original data can be re-sent by the remote end.
I do not know the reason for the overrun not appearing during FCS, assuming bus frequency and baud rate is the same in both instances.
Regards,
Mac