Hello, I am new to the community and to the project I am working on.. I am using a STM32 blue pill board and programming it with a simple code of serial communication :
I am using stm32103c8t6 blue pill board
with generic Stm32f1 series
my doubts :
I previously uploaded a code with memory size >64 kb on the blue pill and it worked and after 10-15 cycles of uploading, the physical board was not working even after i upload the code correctly even with less size.
Now i am using a different stm32blue pill board , but it is having this issue : when I increase the value of i in my code to 2 and after, serial.print suddenly stops working..not even the "working" string is getting printed.
I tried erasing the memory of both boards using stmcube programmer, tried changing board variant to generic stm32f1x, nothing productive has happened yet.
can someone please direct me on this ? its very crucial for my project..
monitor is empty when i replace Serial1 with Serial...
What i am trying to do is increase the number of print statements on my code...
But after 2 statements, the whole serial communication breaks down
You must provide some more information. There are at least two different board-manager packages to program the stm32. Which one do you use?
And there are different possibilities to connect the blue pill to the PC. Did you use the native USB-connection?
What happens if, after loading your sketch, that you disconnect the USB cable from the FTDI device and connect a USB cable between the Bluepill's USB socket and your PC ?
Under tools --> port, do you see other devices apart from COM3 ?
@6v6gt My PC doesn't recognize the com port if I'm connecting usb directly... @horace I had tried this before with the core you are using...still didn't get any results....can you please show the link in the preferences ?
@horace I tried doing exactly what you were.....I am am the point of breakdown sigh nothings working for past few days....both of my stm blue pills blink with a random delay and nothing goes on serial monitor....is stm32duino really a thing ?
Yes, using a direct cable connection between the Bluepill and the PC but:
I use this option for the Bluepill type:
COM3 on my PC is defined but used for an Intel Service. Check that the serial monitor is looking at the right com port:
COM17 here is for the Bluepill.
I am using Serial, not Serial1
void setup() {
Serial.begin(9600);
pinMode(PC13, OUTPUT);
}
void loop() {
Serial.println("Working\n");
delay(1000);
digitalWrite(PC13, LOW);
for (int i = 0; i < 2; i++) {
Serial.println(i++);
delay(100);
}
digitalWrite(PC13, HIGH);
}
I am using ST-Link and the Cube programmer to upload code.
for the serial monitor I use the FTDI board connected to TX1 (PA9) and RX1 (PA10)
the STM32F USB is just to power the device
running the following program
// test of STM32F103C8T6 board LED and serial
#define SerialHW Serial1
void setup() {
while (!Serial);
Serial.begin(115200);
SerialHW.begin(115200);
Serial.println(); Serial.println();
delay(2000);
Serial.println(); Serial.println();
Serial.println("STM32F103C blink and serial test 1");
Serial.println("Serial1 at 115200 baud");
pinMode(PC13, OUTPUT);
}
void loop() {
Serial.println("Working");
SerialHW.println("Working");
delay(1000);
digitalWrite(PC13, LOW);
for (int i = 0; i < 2; i++) {
Serial.println(i++);
SerialHW.println(i++);
delay(100);
}
digitalWrite(PC13, HIGH);
}
a new COM port appears with the Serial monitor output on the STM32 USB
STM32F103C blink and serial test 1
Serial1 at 115200 baud
Working
0
Working
0
Working
0
Working
0
Working
0
Working
0
and on Serial1 (A9 and A10)
Working
1
Working
1
Working
1
if I change to use Serial2
#define SerialHW Serial2
i get error
stm32.ino.cpp:(.text.setup+0x64): undefined reference to `Serial2'
With the STM32, even just the Bluepill, there are a huge number of permutations of core ("roger clark", mapleleaf, 2 versions of the STmicroelectronics core and probably more), bootloader (anyway optional), memory configurations and other configuration options.
At least the OP got plausible messages during software upload so it does not look impossible to solve. There are clones of the STM32F103C8T6 in circulation but I don't think there are many stories in circulation about major incompatibilities.
I was going to point out also that there is a dedicated forum for such issues but, apparently, the OP has already found it: STM32 Serial Communication issues - Arduino for STM32
experimented with a STM B-L072Z-LRWAN1 discovery board (STM32L072CZ micro) - even Serial1 gives undefined reference
The same text appears on the USB COM port and D1 Tx pin
Think I will continue to use STM32cubeIDE for ST boards
// test of STM32F103C8T6 board LED and serial
#define LED_BUILTIN PC13
// hardware serial from https://github.com/stm32duino/wiki/wiki/API#hardwareserial
// RX TX
HardwareSerial Serial2(PA3, PA2);
HardwareSerial Serial3(PB11, PB10);
void setup() {
while (!Serial);
Serial.begin(115200);
Serial1.begin(115200);
Serial2.begin(115200);
Serial3.begin(115200);
Serial.println(); Serial.println();
delay(2000);
Serial.println(); Serial.println();
Serial.println("STM32F103C blink and serial test 1");
Serial.println("Serial3 at 115200 baud");
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
Serial.println("Working");
Serial1.println("Working");
Serial2.println("Working");
Serial3.println("Working");
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
for (int i = 0; i < 2; i++) {
Serial.println(i++);
Serial1.println(i++);
Serial2.println(i++);
Serial3.println(i++);
delay(100);
}
digitalWrite(LED_BUILTIN, HIGH);
// read from port 1, send to port 0:
if (Serial1.available()) {
Serial.print("Serial 1 ");
Serial.println((char)Serial1.read());
}
if (Serial2.available()) {
Serial.print("Serial 2 ");
Serial.println((char)Serial2.read());
}
if (Serial3.available()) {
Serial.print("Serial 3 ");
Serial.println((char)Serial3.read());
}
}
serial2 prints
Working
2
Working
2
Working
2
Serial3 prints
Working
3
Working
3
Working
3
the USB COM port displays as text is entered on Serial1 and Serial3
Working
0
Serial 1 1
Working
0
Serial 1 2
Working
0
Working
0
Working
0
Working
0
Serial 3 5
Working
0
Serial 3 6
Working
0
Working
it is important to close the terminal emulator associated with the USB COM port when new code is being uploaded - once uploaded the USB COM port can be reopened