Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 4 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:
1 Answer
6 years, 3 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!
Thanks to both of you. Much appreciated.
posted by rod palmer 26 Jul 2018