Report
9 months ago.

UART2 and 3 on the L432KC

the chip https://www.st.com/en/microcontrollers/stm32l432kc.html has 3 uarts but the NUCLEO board appears to only have 1 functional uart.

the second one is only half implemented (commented out in the PeripheralPins.c ) and the 3rd one is not mentioned at all.

I am very new to ARM and the mbed environment, is there anything I can do about this ?

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32L432KCU6 microcontroller.

Thanks to both of you. Much appreciated.

posted by rod palmer 26 Jul 2018
Comment on this question

2 Answers

9 months ago.

Hi Rod,

I took a look at the datasheet for the STM32L432KC board here: https://www.st.com/resource/en/datasheet/stm32l432kc.pdf

It looks like this board has a USART1, USART2, and an LPUART1. However, according to the board's PeripheralPins.c file in Mbed OS and the datasheet I listed above, the LPUART TX and RX use the same pins as the USART2 TX and RX. So the board has the following USART's available within Mbed OS by default:

  • USART1: TX = PA_9 or PB_6, RX = PA_10 or PB_7
  • USART2 (connected to STDIO): TX = PA_2, RX = PA_15

If you would like to use the LPUART instead of USART2, I would try changing the lines that are commented out in the PeripheralPins.c file to the following:

MBED_WEAK const PinMap PinMap_UART_TX[] = {
//  {PA_2,       UART_2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)}, // Connected to STDIO_UART_TX
    {PA_2,       LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // Connected to STDIO_UART_TX
    {PA_9,       UART_1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
    {PB_6,       UART_1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
    {NC, NC, 0}
};

MBED_WEAK const PinMap PinMap_UART_RX[] = {
//  {PA_3,       UART_2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART2)},
    {PA_3,       LPUART_1,STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF8_LPUART1)}, // No LPUART_1 TX
    {PA_10,      UART_1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
    {PA_15,      UART_2,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF3_USART2)}, // Connected to STDIO_UART_RX
    {PB_7,       UART_1,  STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF7_USART1)},
    {NC, NC, 0}
};

And then you can use the following Serial object within your application code for the LPUART: Serial serial_object(PA_2, PA_3); //TX, RX

Please let me know if you have any questions!

- Jenny, team Mbed

If this solved your question, please make sure to click the "Thanks" link below!

9 months ago.

Hi,

Jenny's answer is correct.

I would like to mention that using PA2 for LPUART 1 will make you loose the ability of using mbed debug and printf functionalities through hyperterminal (PA2 is the UART that is connected to the STLINK on the nucleo board).

Kind regards

Hi,

this thread describes exactly my problem too, and I'm sure it will be the solution. The only left question: where can I find the file "PeripheralPins.c".

Thanks for your help!

posted by Dieter Riedl 07 Oct 2018

To post an answer, please log in.