AnsweredAssumed Answered

KL17 LPUART noise error with 4 Mhz external crystal

Question asked by Christopher Porter on Apr 3, 2017
Latest reply on Apr 5, 2017 by Kerry Zhou

I had a board with a 48 Mhz crystal and had the LPUART module communicating at 115200 baud with no errors.  Then I swapped out the external clock for one at 4 MHz and the receiver stopped working (the transmitter is still working fine). Communication works if I reduce the baud rate to 9600.  I have verified the following are within tolerance:

!.  External clock speeds;  with scope and also by toggling GPIO with interrupt driven timer.

2. Bit width of data on TX and RX lines

3. Error flags in the LPUART ISR.  We are getting noise error which may suggest phase shifting error.

4. Computation of OSR and SBR.  Baud clock should be 114285 Hz.

 

Below is the code used to set up the UART

 

SIM->SOPT5 = ((SIM->SOPT5 &
(~(SIM_SOPT5_LPUART0TXSRC_MASK | SIM_SOPT5_LPUART0RXSRC_MASK)))
| SIM_SOPT5_LPUART0TXSRC(sopt5LPUART0TxSrc)
| SIM_SOPT5_LPUART0RXSRC(sopt5LPUART0RxSrc)
);

CLOCK_SetLpuart0Clock(2);

lpuart_config_t lpuart_config;
LPUART_GetDefaultConfig(&lpuart_config);
lpuart_config.baudRate_Bps = 115200;
lpuart_config.enableRx = true;
lpuart_config.enableTx = true;

 

LPUART_Init(LPUART0, &lpuart_config, CLOCK_GetFreq(kCLOCK_Osc0ErClk));

LPUART_EnableRx(LPUART0, true);
LPUART_EnableTx(LPUART0, true);
LPUART_EnableInterrupts(LPUART0, kLPUART_RxDataRegFullInterruptEnable);
LPUART_EnableInterrupts(LPUART0, kLPUART_NoiseErrorInterruptEnable | kLPUART_FramingErrorInterruptEnable | kLPUART_RxOverrunInterruptEnable);
EnableIRQ(LPUART0_IRQn);

 

Thank you

Outcomes