Part Number: MSP430FR2155
Hi,
I need a little help on how to sync interrupt and main.
I have a UART connection where data comes, and in the main loop i process this data. Whenever a data comes its stored on ring buffer on interrupt. Main loops runs forever and if there is a new data on ring buffer it process this. I want to implement LPM but i see some risks about it.
Accoring to the below code, if a data comes from UART right after "if(get_size_ring_buffer() < 1)" and before execute this command "__bis_SR_register( LPM3_bits | GIE );" it will be on LPM mode but there would be data on ring buffer which needs to be processed. How i can i solve this problem? Any suggestion?
while(1)
{
if(get_size_ring_buffer() > 0)
{
process_data();
}
if(get_size_ring_buffer() < 1)
{
__bis_SR_register( LPM3_bits | GIE );
{
}
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
{
uint8_t Data;
switch (__even_in_range(UCA1IV, USCI_UART_UCTXCPTIFG))
{
case USCI_UART_UCRXIFG:
Data = EUSCI_A_UART_receiveData(EUSCI_A1_BASE);
ring_buffer_put(rb, &Data)
LPM3_EXIT;
break;
}
}