2430 views|8 replies

73

Posts

0

Resources
The OP
 

How to define the serial port corresponding to GPIO? [Copy link]

 

First, let me show you my Baidu information:

UART(4) is on XA: (TX, RX) = (X1, X2) = (PA0, PA1)

UART(1) is on XB: (TX, RX) = (X9, X10) = (PB6, PB7)

UART(6) is on YA: (TX, RX) = (Y1, Y2) = (PC6, PC7)

UART(3) is on YB: (TX, RX) = (Y9, Y10) = (PB10, PB11)

UART(2) is on: (TX, RX) = (X3, X4) = (PA2, PA3)

But on my micropython STM32F411 board, TX--PA09, RX--PA10, I can't find the corresponding GPIO UART port in the list above. How should I define it? For example, if it is configured to: 9600bps (8-bit data, no parity, 1 stop bit), how should I configure it?

Thank you all in advance.

Latest reply

Thanks for your advice, is there any sample pin definition file for 8266? It would be a good opportunity to learn from it.   Details Published on 2020-7-28 13:57
 
 

1w

Posts

25

Resources
2
 

For the STM32 serial port pins, you first need to define the serial port pins in the mpconfigboard.h file when compiling the firmware. For example, pybv10 and pybv11 are defined as follows:

// UART config
#define MICROPY_HW_UART1_NAME   "XB"
#define MICROPY_HW_UART1_TX     (pin_B6)
#define MICROPY_HW_UART1_RX     (pin_B7)
#define MICROPY_HW_UART2_TX     (pin_A2)
#define MICROPY_HW_UART2_RX     (pin_A3)
#define MICROPY_HW_UART2_RTS    (pin_A1)
#define MICROPY_HW_UART2_CTS    (pin_A0)
#define MICROPY_HW_UART3_NAME   "YB"
#define MICROPY_HW_UART3_TX     (pin_B10)
#define MICROPY_HW_UART3_RX     (pin_B11)
#define MICROPY_HW_UART3_RTS    (pin_B14)
#define MICROPY_HW_UART3_CTS    (pin_B13)
#define MICROPY_HW_UART4_NAME   "XA"
#define MICROPY_HW_UART4_TX     (pin_A0)
#define MICROPY_HW_UART4_RX     (pin_A1)
#define MICROPY_HW_UART6_NAME   "YA"
#define MICROPY_HW_UART6_TX     (pin_C6)
#define MICROPY_HW_UART6_RX     (pin_C7)

In MicroPython, you need to connect the serial port pins according to the above method and cannot modify them at will.

For ESP32, because it supports pin function mapping, many pins can be used for serial ports and can be set flexibly.

Comments

Thank you. I don't know how to compile it myself. When I bought the board, the merchant provided me with the MicroPython firmware. I think there is something wrong with that firmware.  Details Published on 2020-7-27 14:39
Thank you. I don't know how to compile it myself. When I bought the board, the merchant provided me with the MicroPython firmware. I think there is something wrong with that firmware.  Details Published on 2020-7-27 13:59
 
 
 

73

Posts

0

Resources
3
 
dcexpert posted on 2020-7-27 11:34 For the STM32 serial port pins, you first need to define the serial port pins in the mpconfigboard.h file when compiling the firmware. For example, pybv10 and pybv11 are...

Thank you. I don't know how to compile it myself. When I bought the board, the merchant provided me with the MicroPython firmware. I think there is something wrong with that firmware.

Comments

Firmware compilation is not difficult, you can refer to the community post Compiling MicroPython in the Ubuntu subsystem of Windows 10  Details Published on 2020-7-27 15:50
 
 
 

128

Posts

0

Resources
4
 
dcexpert published on 2020-7-27 11:34 For the STM32 serial port pins, you first need to define the serial port pins in the mpconfigboard.h file when compiling the firmware. For example, pybv10 and pybv11 are...

According to what the moderator said, we can match the pins of 8266 or ESP32 with the pins in the program? Instead of having to use those irrelevant things? If I want to match the pin numbers on the print with the numbers referenced in the program, what should I do?

Comments

ESP8266 has fewer pins and relatively fewer functions. It only has one and a half serial ports, and REPL occupies one. ESP32 is much more powerful. Many pins support function mapping and can be customized to PWM, serial port, I2C, SPI, WS2812 and other functions. Some pins can only be used for ADC, and DAC pins are also fixed.  Details Published on 2020-7-27 15:52
 
 
 

1w

Posts

25

Resources
5
 
ywb888 posted on 2020-7-27 13:59 Thank you. I don’t know how to compile it myself. When I bought the board, the merchant provided the MicroPython firmware. I think there is something wrong with that firmware.

Firmware compilation is not difficult, you can refer to the community post

Compile micropython under ubuntu subsystem of win10

 
 
 

1w

Posts

25

Resources
6
 
9zhmke posted on 2020-7-27 14:39 dcexpert posted on 2020-7-27 11:34 For the pins of the STM32 serial port, you first need to add them in the mpconfigboard.h file when compiling the firmware...

ESP8266 has fewer pins and relatively fewer functions, with only one and a half serial ports, and REPL occupies one. ESP32 is much more powerful.

Many pins support function mapping and can be customized to PWM, serial port, I2C, SPI, WS2812, etc. Some pins can only be used as ADC, and DAC pins are also fixed and cannot be changed.

Comments

Last time I bought 50 8266s for students to get started with, but many students often confuse the pin numbers on the circuit board with the port pin numbers defined in the program. Is there any way to correct this?  Details Published on 2020-7-27 23:32
 
 
 

128

Posts

0

Resources
7
 
dcexpert posted on 2020-7-27 15:52 ESP8266 has fewer pins and relatively fewer functions. It has only one and a half serial ports, and REPL occupies one. ESP32 is much more powerful. ...

Last time I bought 50 8266s for students to get started with, but many students often confuse the pin numbers on the circuit board with the port pin numbers defined in the program. Is there any way to correct this?

Comments

For students who are just starting to learn, it may be easy to make mistakes. You can draw a pin diagram and mark the pin definitions. Or you can write a separate pin definition file and use it by name instead of number, which can also avoid some problems.   Details Published on 2020-7-28 09:12
 
 
 

1w

Posts

25

Resources
8
 
9zhmke posted on 2020-7-27 23:32 Last time I bought 50 8266s for students to get started, but many students often confuse the pin numbers on the circuit board with the port pin numbers defined in the program. Is there a way to solve this problem?

For students who are just starting to learn, it may be easy to make mistakes. You can draw a pin diagram and mark the pin definitions. Or you can write a separate pin definition file and use it by name instead of number, which can also avoid some problems.

 
 
 

128

Posts

0

Resources
9
 

Thanks for your advice, is there any sample pin definition file for 8266? It would be a good opportunity to learn from it.

 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list