Nucleo STM32F411 change Pin UART

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
P@T
Posts: 33
Joined: Tue Nov 06, 2018 2:37 pm

Nucleo STM32F411 change Pin UART

Post by P@T » Sat Apr 18, 2020 10:21 am

Hi,

I work with a nucleo F411 but i have a problem with UART on the "ARDUINO HEADER".
I use the UART6 on the NUCLEO HEADER but it's missing on the ARDUINO-HEADER.

Can I redirect the UART6 to the pin's of UART1 without rebuilding the firmware ?

In mpconfigboard.h there don't UART1
// UART config
#define MICROPY_HW_UART2_TX (pin_A2)
#define MICROPY_HW_UART2_RX (pin_A3)
#define MICROPY_HW_UART6_TX (pin_C6)
#define MICROPY_HW_UART6_RX (pin_C7)
// UART 2 connects to the STM32F103 (STLINK) on the Nucleo board
// and this is exposed as a USB Serial port.
#define MICROPY_HW_UART_REPL PYB_UART_2
#define MICROPY_HW_UART_REPL_BAUD 115200
I have read the post of dhylands : viewtopic.php?t=5795#p33338.
If I have to rebuild the firmware and the file "pin.csv" contains all the pins, there is nothing else to modify in the file "mpconfigboard.h" before compiling ?

Thank you

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Nucleo STM32F411 change Pin UART

Post by jimmo » Sat Apr 18, 2020 12:19 pm

Sorry I'm not quite sure exactly what you're asking so I'll try and cover a few different things:

- This chip has 3 UARTs (1, 2, 6).
- For some reason, the board definition only configures two of them (2 and 6) so only two will be available from MicroPython (without modifying mpconfigboard.h and building the firmware). (i.e. you will only be able to construct machine.UART(2) and machine.UART(6))
- Each UART is available on multiple pins via the Alternate Function mechanism. The defaults are in mpconfigboard.h, but you can choose the alternate functions from MicroPython (this is available on machine.Pin). You can look up the alternate functions in the F411 datasheet, otherwise MicroPython's stm32f411_af.csv file.

Code: Select all

$ for FN in USART{1,2,6}_{TX,RX}; do echo $FN; cat ports/stm32/boards/stm32f411_af.csv | grep $FN | cut -d, -f2; echo; done
USART1_TX
PA9
PA15
PB6

USART1_RX
PA10
PB3
PB7

USART2_TX
PA2
PD5

USART2_RX
PA3
PD6

USART6_TX
PA11
PC6

USART6_RX
PA12
PC7
So if you want to use UART6 on the Arduino header, you need to find PA11 or PC6, and PA12 or PC7 on the Arduino header. But of those four, only unfortunately only PC7 (i.e. TX) is on the Arduino header.

Which gives you two options:
- Use UART1 instead, i.e. add it to mpconfigboard.h and build the firmware. (TX=PA9 (on D8), RX=PA10 (on D2) or PB3 (on D3)).
- Find a spare pin on the Arduino header that is also on the Nucleo header, set that pin to input mode, and then jumper it to PC6 on the Nucleo header (or PA11, but then you'll have to configure the alternate function).

P@T
Posts: 33
Joined: Tue Nov 06, 2018 2:37 pm

Re: Nucleo STM32F411 change Pin UART

Post by P@T » Sun Apr 19, 2020 9:51 am

Hi jimmo

I'm sorry, it's because of my English.
You have answered my question. I'm going to rebuild the firmware.

Thank you very much

Post Reply