Hi,
I am trying to read UART RX Buffer after UCRXIFG triggered USCI_A0_VECTOR interruption. When I don't enter LPM4 or if I exist LPMx at the end of my interruption I am able to retrieve the whole buffer without error. But If I am in LPM4 I have UCA0STAT = 0x6C (Framing Error, OverRun Error, Break Error) and I receive 3 incorrect bytes if UCRXEIE = 1.
Data that I want to retrieve are acknowledgement of a TX message. When I have the error, I retry sending this message and I have a correct ACK without any error.
In my main continous loop, I manage the enter in LPM like this :
// Low power mode when done if(sync_OperationState.Probes || sync_OperationState.TM) { TIMERB0_EN; __bis_SR_register(LPM0_bits + GIE); } else { TIMERB0_DIS; __bis_SR_register(LPM4_bits + GIE); }
My timerB0 is here to trigger an interrupt every 10ms when I am frequently using my MCU. Otherwise I have a timerA0 which trigger an interrupt every seconds.
And here is how I manage my UCA interruption. If I uncomment the last line "// __low_power_mode_off_on_exit();" it works everytime.
#pragma vector=USCI_A0_VECTOR __interrupt void USCI_A0_ISR(void) { uca0_Stat_Before = UCA0STAT; switch(__even_in_range(UCA0IV,4)) { case 0: // Vector 0 - no interrupt break; case 2: // Vector 2 - RXIFG // Update of the receive buffer uca0_NbreReceivedValue++; *WritePointer[RXBUFFER]++ = UCA0RXBUF; if(WritePointer[RXBUFFER] == &RXBuffer[UCA0_RXBUFFERSIZE]) WritePointer[RXBUFFER] = RXBuffer; break; case 4: // Vector 4 - TXIFG // Send a byte if necessary and update of the transmission buffer SendingInProgress = FALSE; if(ReadPointer[TXBUFFER] != WritePointer[TXBUFFER]) { SendingInProgress = TRUE; UCA0TXBUF = *ReadPointer[TXBUFFER]++; if(ReadPointer[TXBUFFER] == &TXBuffer[UCA0_TXBUFFERSIZE]) ReadPointer[TXBUFFER] = TXBuffer; } break; default: break; } uca0_Stat_After = UCA0STAT; // __low_power_mode_off_on_exit(); }
This issue seems to be highly related to the fact that I am in LPM but I can't explain why I have this behavior.