Hi all, I have a problem with USART interrupts, it is the first time I use them, I would also appreciate if someone could tell me where I can find some information about them.
I am using a LPC55SS14.
I am trying to receive data from an external device to the micro via the USART interrupt method. I have followed NXP examples and it did not work for me.
The problem is as follows: The MCU is detecting the interrupt, what happens is that it goes through it 3 or 4 times having only received one interrupt. I think it may be because it is not able to read all the information coming from the port, I am receiving 5 bytes, I have tried different ways but I have not been able to find the solution for the moment.
Another curious fact that I think is important to mention is that if I put a breakpoint in the first lines of the interrupt, it only enters it once and it does it correctly, however, if I put the breakpoint at the end of the interrupt instead of at the beginning, the failure mentioned above is repeated.
I have also used different read methods, USART_ReadBlocking, USART_ReadByte....
Attached is the code part of the interrupt.
Thank you very much.
Best regards.
/* FLEXCOMM2_IRQn interrupt handler */
void FLEXCOMM2_FLEXCOMM_IRQHANDLER(void)
{
uint8_t data[5];
if ((kUSART_RxFifoNotEmptyFlag | kUSART_RxError) & USART_GetStatusFlags(FLEXCOMM2_PERIPHERAL))
{
//
data [0] = USART_ReadByte(FLEXCOMM2_PERIPHERAL);
data [1] = USART_ReadByte(FLEXCOMM2_PERIPHERAL);
data [2] = USART_ReadByte(FLEXCOMM2_PERIPHERAL);
data [3] = USART_ReadByte(FLEXCOMM2_PERIPHERAL);
data [4] = USART_ReadByte(FLEXCOMM2_PERIPHERAL);
}
#if defined __CORTEX_M && (__CORTEX_M == 4U)
__DSB();
#endif
// SDK_ISR_EXIT_BARRIER;
vTaskNotifyGiveFromISR(_tskHandleCntDh, &tskWoken);
SDK_ISR_EXIT_BARRIER;
}