Using LPUART2 on FRDM-947 - need to do anything special?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using LPUART2 on FRDM-947 - need to do anything special?

1,049 Views
mkraft
Contributor II

I want to use LPUART2 on the FRDM-947 to take in DMX512 on Core1. It appears I can only use framing error to catch the long break of this protocol. My issue is actually getting this to work at all. 

I get an initial framing error, though it is occurring once right after interrupt enabled and before I start to transmit DMX to the FRDM board.

Here is code snippet to set pins and initialize the uart:

port_pin_config_t pin_cfg = {0};

 

/*

* RX-only DMX lines. Pull-up keeps the pin at a defined MARK

* level when no cable is connected.

*

* P4_3 Alt2 = FC2_RXD_SDA_MOSI_DATA (Flexcomm2 RXD)

* P1_16 Alt2 = FC5_RXD_SDA_MOSI_DATA (Flexcomm5 RXD)

*

* Verify Alt function codes against the MCXN947 RM pin-mux table

* or use the MCUXpresso Pins Config Tool.

*/

pin_cfg.pullSelect = kPORT_PullUp;

pin_cfg.pullValueSelect = kPORT_HighPullResistor;

pin_cfg.inputBuffer = kPORT_InputBufferEnable;

pin_cfg.invertInput = kPORT_InputNormal;

pin_cfg.slewRate = kPORT_SlowSlewRate;

pin_cfg.passiveFilterEnable = kPORT_PassiveFilterDisable;

pin_cfg.openDrainEnable = kPORT_OpenDrainDisable;

 

/* CH0 — P4_3 */

CLOCK_EnableClock(kCLOCK_Port4);

pin_cfg.mux = kPORT_MuxAlt2;

PORT_SetPinConfig(PORT4, 3U, &pin_cfg);

 

/* CH1 — P1_16 */

CLOCK_EnableClock(kCLOCK_Port1);

pin_cfg.mux = kPORT_MuxAlt2;

PORT_SetPinConfig(PORT1, 16U, &pin_cfg);

lpuart_config_t cfg;

uint32_t lpclk;

 

/* Attach FRO12M clock then gate the peripheral */

if (ch == DMX_CH0)

{

CLOCK_AttachClk(kFRO12M_to_FLEXCOMM2);

lpclk = CLOCK_GetLPFlexCommClkFreq(2);

}

else

{

CLOCK_AttachClk(kFRO12M_to_FLEXCOMM5);

lpclk = CLOCK_GetLPFlexCommClkFreq(5);

}

CLOCK_EnableClock(s_lpuart_clock[ch]);

 

 

LPUART_GetDefaultConfig(&cfg);

cfg.baudRate_Bps = DMX_BAUD_RATE;

cfg.parityMode = kLPUART_ParityDisabled;

cfg.dataBitsCount = kLPUART_EightDataBits;

cfg.stopBitCount = kLPUART_TwoStopBit;

cfg.enableRx = true;

cfg.enableTx = false;

cfg.rxFifoWatermark = 0;

 

LPUART_Init(s_lpuart_base[ch], &cfg, lpclk);

 

LPUART_EnableInterrupts(s_lpuart_base[ch],

kLPUART_RxDataRegFullInterruptEnable |

kLPUART_FramingErrorInterruptEnable |

kLPUART_RxOverrunInterruptEnable);

 

NVIC_SetPriority(s_lpuart_irq[ch],

0);

EnableIRQ(s_lpuart_irq[ch]);

Labels (1)
0 Kudos
Reply
1 Reply

996 Views
mkraft
Contributor II

Problem solved.

Flexcomm2 on pins 4_3 and P4_2 for rxd and txd are signals FC2_P3 and FC2_P2 respectively.

Per the reference manual, this is only available when the Flexcomm2 mode is LPUART+LPI2C.

a call to

LP_FLEXCOMM_Init(LPUART_GetInstance(s_lpuart_base[ch]), LP_FLEXCOMM_PERIPH_LPI2CAndLPUART);

must be made after the driver call to LPUART_Init as this function will set the Flexcomm mode to just LPUART.

 

LPFLEXCOMM_INIT_NOT_USED_IN_DRIVER can be defined so that this change doesn't occur as well.

 

0 Kudos
Reply