Hi
I'm currently trying to map the UART2 Hardware serial pins on a STM32G0B1CBT to PA15 and PA14, however it doesn't seem to be taking effect.
On a different board, the BlackPill / STM32F401CC the code below works to change the hardware pins of the serial port
Code: Select all
// RX TX
//HardwareSerial Serial2(PA10, PA9);
HardwareSerial Serial2(PB7, PB6);
void setup() {
Serial2.begin(9600);
}
void loop() {
Serial2.println("HB");
delay(10);
}
However using the code adapted for the STM32G0B1CBT6 it does not, nor does it show any compiling issues.
Code: Select all
// RX TX
//HardwareSerial Serial2(PD6, PD5); //Pins not available on STM32G0B1CBT6
HardwareSerial Serial2(PA15, PA14);
//HardwareSerial Serial2(PA3, PA2);
void setup() {
Serial2.begin(9600);
}
void loop() {
Serial2.println("HB");
delay(10);
}
Looking at the data sheet USART 2 can be mapped to the following pins
USART2_RX PD6, PA15, PA3
USART2_TX PD5, PA14, PA2
With PD5 & PD6 being the default for USART2
Any help that can be offered is greatly appreciated
by ag123 » Mon Aug 22, 2022 1:34 pm
there are some additional pin mapping codes in the variant e.g.
https://github.com/stm32duino/Arduino_C ... ins.c#L175
you may like to take a look at those definitions and perhaps review HardwareSerial codes?
but it do look like PA14 TX, PA15 RX are valid pins
there is a catch though
Code: Select all
WEAK const PinMap PinMap_UART_TX[] = {
...
{PA_14, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)},
{PA_14_ALT1, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)},
...
}
WEAK const PinMap PinMap_UART_RX[] = {
...
{PA_13, LPUART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF10_LPUART2)},
{PA_15, USART2, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_PULLUP, GPIO_AF1_USART2)},
...
}
PA14 has 2 alt function pin mappings, it may take more study there
Go to full post