Use RT1060 STAT[LBKDE] to detect Lin "break",but cannot receive Lin data

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Use RT1060 STAT[LBKDE] to detect Lin "break",but cannot receive Lin data

813 次查看
FanXinhao
Contributor II

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
}
标记 (1)
0 项奖励
回复
1 回复

789 次查看
kerryzhou
NXP TechSupport
NXP TechSupport

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

https://community.nxp.com/t5/NXP-Designs-Knowledge-Base/RT1170-LIN-driver-development-and-stack-port...

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

 

0 项奖励
回复