hi,I use RT1060 to detect Lin "break" by set LPUART Status Register (STAT)[LBKDE],that can trigger "kLPUART_LinBreakFlag" interrupt.But section of data cannot receive.
init uart and set STAT[LBKDE]:
static void LPUART2_init(void) {
LPUART_Init(LPUART2_PERIPHERAL, &LPUART2_config, LPUART2_CLOCK_SOURCE);
((LPUART_Type *)LPUART2_PERIPHERAL)->STAT |= LPUART_STAT_LBKDE(1);
LPUART_EnableInterrupts(LPUART2_PERIPHERAL, kLPUART_LinBreakInterruptEnable | kLPUART_RxDataRegFullInterruptEnable | kLPUART_RxOverrunInterruptEnable | kLPUART_TxFifoOverflowInterruptEnable | kLPUART_RxFifoUnderflowInterruptEnable);
/* Enable interrupt LPUART2_IRQn request in the NVIC. */
EnableIRQ(LPUART2_SERIAL_RX_TX_IRQN);
}
interrupt handle:
void LPUART2_SERIAL_RX_TX_IRQHANDLER(void) {
uint32_t intStatus;
status_t status;
/* Reading all interrupt flags of status registers */
intStatus = LPUART_GetStatusFlags(LPUART2_PERIPHERAL);
status = LPUART_ClearStatusFlags(LPUART2_PERIPHERAL, intStatus);
/*my code start */
if (intStatus & kLPUART_LinBreakFlag)
{
PRINTF("kLPUART_LinBreakFlag\r\n"); //It can be call
}
if (intStatus & kLPUART_RxDataRegFullFlag)
{
PRINTF("kLPUART_RxDataRegFullFlag\r\n"); //It cannot execute
PRINTF("data = 0x%x\r\n", LPUART_ReadByte(LPUART2_PERIPHERAL));
}
/*my code end*/
#if defined __CORTEX_M && (__CORTEX_M == 4U)
__DSB();
#endif
}
Hi @FanXinhao
About the RT LIN, you can refer to the following post and AN, it also contains the project code which is useful to you:
1. UART connect to the external LIN transiver
You can check the code which is using UART for the LIN.
Although it is RT1170, but RT1060 still can refer to it.
2. FlexIO simulate the LIN
https://www.nxp.com/docs/en/application-note/AN12788.pdf
Best Regards,
Kerry