Hello,
I have a KL82 which I attached a modem to it. It communicates via UART.
If the bus is busy (message every second) everything works fine. But if there is rarely any activity (about once a minute) the interrupt for UART RX does not fire when the modem sends data.
This is resolved by reinitializing the UART.
Do you know why this occurs or how I can debug more deeply? Thanks a lot in advance.
Here is my ISR code for reference
void MODEM_LPUART_IRQHandler(void)
{
#ifdef TRACE_SYSVIEW_LPUART_CALLBACK
SEGGER_SYSVIEW_RecordEnterISR();
#endif
interfaceModem_hasWoken = pdFALSE;
/** if new data is in buffer */
if ((kLPUART_RxDataRegFullFlag)&LPUART_GetStatusFlags(MODEM_LPUART))
{
TPM_StopTimer(TPM0); /** stop timer for timeout detection */
interfaceModem_data = LPUART_ReadByte(MODEM_LPUART); /** read data from buffer */
if (uxQueueMessagesWaitingFromISR(InterfaceModem::rxQueue)<INTERFACE_MODEM_RX_QUEUE_SIZE-3)
{ /** Submit to queue */
xQueueSendFromISR(InterfaceModem::rxQueue,&interfaceModem_data,&interfaceModem_hasWoken);
if (interfaceModem_data=='\n')
{ /** if this char is a line ending, activate the timer. Every Message of SIM808 ends with */
TPM_SetTimerPeriod(TPM0,TIMER_MESSAGETIMEOUT_RELOAD_VALUE);
TPM_StartTimer(TPM0,kTPM_SystemClock);
TPM0->CNT=0;
}
}
else
{ /** If data could not be submitted, set overflow occured, clear queues and stop timeout timer */
InterfaceModem::rxOverflowOccured=1;
TPM_StopTimer(TPM0);
xQueueReceiveFromISR(InterfaceModem::rxMessageTimeoutSignalQueue,&interfaceModem_data,&interfaceModem_hasWoken);
while (xQueueReceiveFromISR(InterfaceModem::rxQueue,&interfaceModem_data,&interfaceModem_hasWoken)==pdTRUE);
InterfaceModem::rxOverflowOccured=1;
}
}
/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
exception return operation might vector to incorrect interrupt */
#if defined __CORTEX_M && (__CORTEX_M == 4U)
__DSB();
#endif
#ifdef TRACE_SYSVIEW_LPUART_CALLBACK
SEGGER_SYSVIEW_RecordExitISR();
#endif
portYIELD_FROM_ISR(interfaceModem_hasWoken);
}