UART and CAN not working in STM32F103RCT6

Good afternoon. After updating the arduino core, SERIAL and CAN stopped working.
platform = ststm32@13 — works
platform = ststm32@15 — doesn’t work.
Tried using

build_flags=
  -D HAVE_HWSERIAL1
  -D ENABLE_HWSERIAL1
  -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
  -D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF.

doesn’t working. I ask for help

In… compiles but doesn’t work at runtime, or does not compile? What’s the code, full platformio.ini and complete error message?

Okay. I am using STM32F103RCT6 microcontroller. My code is very large, so I created a simple project where only UART is used. This code compiles without problems, but the UART output is empty. If you change the kernel version in platform.ini platform = ststm32@13 or lower. Then the UART pin works without problems.

main.cpp

#include <Arduino.h>
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.print(“test”);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.print(“test”);
delay(1000);
}

platform.ini

[env:genericSTM32F103RC]
platform = ststm32
board = genericSTM32F103RC
framework = arduino

Where are you connecting the UART RX pin of your USB-Serial adapter to? It’s on PA2.

Also, you might want to use Serial.println() to add a linebreak, or Serial.flush() to force the output to be flushed.

Yes, I noticed that in the old kernel file these pins are indicated on UART1 PA10 PA9, and in the new PA3 PA2

stm32duino/Arduino_Core_STM32/blob/main/variants/STM32F1xx/F103R(CDE)T/variant_generic.h#L173-L184

I changed the value here to PA10 PA9 still does not work (

Use

build_flags=
  -DSERIAL_UART_INSTANCE=1
  -DPIN_SERIAL_TX=PA9
  -DPIN_SERIAL_RX=PA10

instead and no source modifications. (Or switch tx and Rx pins, not sure right now)

2 Likes

Thanks, it worked. And do not tell me what to do with CAN. Also after updating the kernel does not send anything

1 Like

…What’s the code you’re using for CAN?

i use the library GitHub - exothink/eXoCAN: stm32duino CAN Library for the STM32F103 aka Blue Pill. Example eXoCanDataSim

Does it work when using the Arduino IDE and the GitHub - stm32duino/Arduino_Core_STM32: STM32 core support for Arduino core version 2.2.0? If not, better open an issue at the library.