Part Number: MSP430FR5969
I am using the MSP430FR5969 on my board. My UART configuration is :
// Setting for 16 MHz clock (230400)
EUSCI_A_UART_initParam param = {0};
param.selectClockSource = EUSCI_A_UART_CLOCKSOURCE_SMCLK;
param.clockPrescalar = 4;
param.firstModReg = 5;
param.secondModReg = 0x55;
param.parity = EUSCI_A_UART_NO_PARITY;
param.msborLsbFirst = EUSCI_A_UART_LSB_FIRST;
param.numberofStopBits = EUSCI_A_UART_ONE_STOP_BIT;
param.uartMode = EUSCI_A_UART_MODE;
param.overSampling = EUSCI_A_UART_OVERSAMPLING_BAUDRATE_GENERATION;
if (STATUS_FAIL == EUSCI_A_UART_init(EUSCI_A0_BASE, ¶m))
return;
EUSCI_A_UART_enable(EUSCI_A0_BASE);
EUSCI_A_UART_clearInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT);
// Enable USCI_A0 RX interrupt
EUSCI_A_UART_enableInterrupt(EUSCI_A0_BASE, EUSCI_A_UART_RECEIVE_INTERRUPT); // Enable interrupt
I have unknow packet size on the UART RX hence I start out by using UART in interrupt mode for receiving the first byte and then disabling the interrupt till all the bytes have been received. I cannot discuss the framing technique I am using but assume it works.
Once the complete packet is received I enable the UART interrupt again. For polling the UART data I am using
inline char UART_getChar (void)
{
while (!(UCA0IFG&UCRXIFG)); // RX buffer got data ?
return UCA0RXBUF;
}
The MSP gets the packet every 1 sec. The issue I am having is that randomly (could be 10 packets or 2000+ packets later) the code gets stuck and spins on the while loop "while (!(UCA0IFG&UCRXIFG)); // RX buffer got data ? ". I know for a fact that the board is receiving a packet every second continuously. I checked the UCA0IFG and it is stuck at 0. Can you please help with this issue? Is there something with the code or is this an issue with the microprocessor ? I cannot share my full code. TIA