Initialize Uart ports on FRDM-Kl43Z

cancel
Showing results for 
Search instead for 
Did you mean: 

Initialize Uart ports on FRDM-Kl43Z

342 Views
Contributor I

Hi,

 

I would like to initialize and exchange data over a Uart port on the board FRDM-KL43Z. Currently, I'm able to initialize receive and send data to a virtual terminal (tera term) using these functions:

 

lpuart_status_t LPUART_DRV_Init(uint32_t instance, lpuart_state_t * lpuartStatePtr,

                                const lpuart_user_config_t * lpuartUserConfig);

 

lpuart_status_t LPUART_DRV_SendData(uint32_t instance,

 

                                    const uint8_t * txBuff,

                                    uint32_t txSize);

 

lpuart_status_t LPUART_DRV_ReceiveData(uint32_t instance,

 

                                       uint8_t * rxBuff,

                                       uint32_t rxSize);

 

Currently, for the Uart instance parameter in these functions, I use the BOARD_DEBUG_UART_INSTANCE macro. But, I would like to use another Uart port on the FRDM KL43Z than the one connected to the openSDA. I didn't find any documentation mapping the different Uart port on arduino headers to instances in the code. In other words, for example, what should I put for the uint32_t instance parameter in the functions above to initialize the PTE20 and PTE21 port on the board (Or any other Uart port)?

 

Thank you

Labels (1)
1 Reply

22 Views
NXP Employee
NXP Employee

The KL43Z has 2 UART "instances", LPUART0 and LPUART1. The BOARD_DEBUG_UART_INSTANCE macro is likely the base address of the LPUART0 module, which according to the KL43 Signal Multiplexing and Pin Assignments, can be brought out on PTE20/21. You just need to change the pin muxing in your init code.

/* Ungate the port clock */

CLOCK_EnableClock(kCLOCK_PortE);

/* Initialize LPUART0 pins */

PORT_SetPinMux(PORTE,20u,kPORT_MuxAlt4); /* UART0_TX */

PORT_SetPinMux(PORTE,21u,kPORT_MuxAlt4); /* UART0_RX */