How to change the uart port from Uart4 to Uart3 in the mcuxpresso SDK uart examples.
Board: i.MX8MPlus EVK
mcuxpresso SDK: 2.14.0
The default port for the uart examples are always UART4. We wanted to use the UART3 on the expansion connector from the Cortex-M7. We did the following adaptions but no signals comes out of Uart3 on the expansion connector.
Question I:
Do we need any other changes to get it work?
What we have done: we took one Uart example and changed the UART4 in the following lines (in (1) ...(5)) to Uart3:
(1) #define DEMO_UART UART4
(2) Clock
board.h:26: CLOCK_GetPllFreq(kCLOCK_SystemPll1Ctrl) / (CLOCK_GetRootPreDivider(kCLOCK_RootUart4)) / \
board.h:27: (CLOCK_GetRootPostDivider(kCLOCK_RootUart4)) / 10
(3) IRQ
board.h:28:#define BOARD_UART_IRQ UART4_IRQn
board.h:29:#define BOARD_UART_IRQ_HANDLER UART4_IRQHandler
(4) clock configuration (According to the processor document, it seems that the Uart3 can use the same clock source as Uart4)
clock_config.c:105: CLOCK_SetRootMux(kCLOCK_RootUart4, kCLOCK_UartRootmuxSysPll1Div10); /* Set UART source to SysPLL1 Div10 80MHZ */
clock_config.c:106: CLOCK_SetRootDivider(kCLOCK_RootUart4, 1U, 1U);
(5) pinmux
pin_mux.c:58: IOMUXC_SetPinMux(IOMUXC_UART4_RXD_UART4_RX, 0U);
pin_mux.c:59: IOMUXC_SetPinConfig(IOMUXC_UART4_RXD_UART4_RX,
pin_mux.c:62: IOMUXC_SetPinMux(IOMUXC_UART4_TXD_UART4_TX, 0U);
pin_mux.c:63: IOMUXC_SetPinConfig(IOMUXC_UART4_TXD_UART4_TX, ...)
Question II:
There is a yaml section in the pin_mux.c (generated from PinMux Tools). Will they be used in building the Uart driver?
pin_mux.c:46: - {pin_num: AJ5, peripheral: UART4, signal: uart_rx, pin_signal: UART4_RXD, PE: Enabled, HYS: CMOS, PUE: Weak_Pull_Up, FSEL: Slow, DSE: X1}
pin_mux.c:47: - {pin_num: AH5, peripheral: UART4, signal: uart_tx, pin_signal: UART4_TXD, PE: Enabled, HYS: CMOS, PUE: Weak_Pull_Up, FSEL: Slow, DSE: X1}
If this is the case, does it mean the pin_mux.c has to be regenerated by adding Uart3?
Do you have any examples pin_mux.c where Uart3 is configured?
Many thanks and best regards
Hi @Z2025121 !
Thank you for contacting NXP Support!
You have to configure the UART3 on "imx8mp_bl31_setup.c" of the ATF.
Please add the line "RDC_PDAPn(RDC_PDAP_UART2, D1R | D1W)" to declare the UART3 on the M core domain.
https://github.com/nxp-imx/imx-atf/blob/lf_v2.6/plat/imx/imx8m/imx8mp/imx8mp_bl31_setup.c#L138
https://github.com/nxp-imx/imx-atf/blob/lf_v2.6/plat/imx/imx8m/imx8mp/imx8mp_bl31_setup.c#L76
If you want to use Linux and the M core you should remove from the device tree the UART3
https://github.com/nxp-imx/linux-imx/blob/lf-6.1.y/arch/arm64/boot/dts/freescale/imx8mp-evk.dts#L954
Best Regards!
Alejandro
Hi Alejandro,
Thanks for the hint for the Linux case for A-core. But we looking for Uart3 configuration in mcuxpresso SDK for Cortex-M7.
Uart3 on the expansion connector is routed to AC20 UART3_TXD, AF20 UART3_RXD. We have generated the pin_mux by using the online pin tool.
Question:
We are unsure if the settings in the YMAL part are correct when we use the same parameters as Uart4 for HYS, PUE, FSEL and DSE. Are these settings correct?
Hi @Z2025121!
You have to declare the UART3 on the M Core domain by changing the bootloader (On the BL31 phase), if you don't change the BL31 the UART3 is only used by A core.
Please try to modify the ATF and then debug your M-core application.
Best Regards!
Chavira