This is known debugging issue.
The problem is that RDRF flag is cleared by reading of SCISR register followed by reading SCIDR register.
When we stop MCU at start of interrupt routine by breakpoint, debugger will automatically read content of registers (and memory) and this way also clear RDRF flag.
Solution: You have to store SCISR register value to some variable at begin of interrupt routine and place breakpoint below this command. After that you could test that variable instead SCISR register for flags.
So, after reaching breakpoint, you could continue in stepping over code.
For example:
#pragma CODE_SEG NON_BANKED
interrupt 20 void SCI0_Isr(void)
{
//---------------
//prection against randomly flag clearing
unsigned char scisr1;
scisr1 = SCI0SR1; // save status register actual status
//---------------
//******************************************************************************
//Interrupt runtine RECEIVER part
//******************************************************************************
//if receiver interrupt is enabled and corresponding interrupt flag is set
if((SCI0CR2 & SCI0CR2_RIE_MASK) && ((scisr1 & (SCI0SR1_OR_MASK | SCI0SR1_RDRF_MASK))))
{
if(scisr1 & SCI0SR1_OR_MASK) // if overrun error do nothing/something
{
(void)SCI0DRL; // clear interrupt flag
// do something
}
else
{
//ninth_bit=SCI0DRH_R8; //R8 is the ninth data bit received when the SCI is configured for 9-bit data format (M = 1).
sc0_data_in = SCI0DRL; // read received character + clear interrupt flag
}
//…
I hope it helps you.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------