Page 1 of 1

Serial 3 is not declared

Posted: Tue Dec 24, 2019 8:25 am
by avip
I am trying to use stm32f103c8t6 board with 3 serial ports : Serial 1,2,3
Serial 1,2 are able to compile, but I get error on Serial 3.
What is the problem?

Re: Serial 3 is not declared

Posted: Tue Dec 24, 2019 3:28 pm
by fpiSTM
Which core you used and how?
To get support please be more precise ;)

Re: Serial 3 is not declared

Posted: Tue Dec 24, 2019 7:27 pm
by avip
I am using this board
https://www.ebay.com/itm/Minimum-System ... 2749.l2649

Model: STM32F103C8T6.
Core: ARM 32 Cortex-M3 CPU.
Debug mode: SWD.
72MHz work frequency.
64K flash memory, 20K SRAM.
2.0-3.6V power, I/O.

Re: Serial 3 is not declared

Posted: Wed Dec 25, 2019 3:53 pm
by tomtom381
The board you are using is called the Blue Pill.

There are two "cores" available that provide an Arduino API for these boards. So fpiSTM wants to know whether you use the Arduino_Core_STM32 one or the Arduino_STM32. And you can use these cores with the Arduino IDE and with platform.io. So the question is: which setup are you using?

Re: Serial 3 is not declared

Posted: Wed Dec 25, 2019 6:09 pm
by fredbox
Also need to know if you have installed a bootloader.

If using the original "Roger" Arduino STM32 core and the generic bootloader,
Serial = USB Serial
Serial1 = UART1
Serial2 = UART2
Serial3 = UART3

Without the bootloader,
Serial = UART1
Serial1 = UART2
Serial2 = UART3

See https://github.com/rogerclarkmelbourne/ ... /board.cpp near the end of the file.

I have not looked at how the Arduino Core STM32 defines the serial ports.

Re: Serial 3 is not declared

Posted: Wed Dec 25, 2019 8:15 pm
by fredbox
For the Arduino Core STM32, Serial1 through Serial3 are undefined on the blue pill. Before the setup statement, insert:

Code: Select all

HardwareSerial Serial1(PA10, PA9); 
HardwareSerial Serial2(PA3, PA2);
HardwareSerial Serial3(PB11, PB10);
Reference: https://github.com/stm32duino/wiki/wiki ... wareserial

Then you can use Serial1.begin(9600), Serial1.print(), etc.

Re: Serial 3 is not declared

Posted: Fri Dec 27, 2019 7:03 am
by avip
Thanks. I wasnt able to operate the roger bootloader. I got undefined usb connection on win10. So, I will stay with 3 uarts and now I am looking for software uart on mu bluepill.
Is it possible?

Re: Serial 3 is not declared

Posted: Fri Dec 27, 2019 7:19 pm
by Bingo600
avip wrote: Fri Dec 27, 2019 7:03 am Thanks. I wasnt able to operate the roger bootloader. I got undefined usb connection on win10. So, I will stay with 3 uarts and now I am looking for software uart on mu bluepill.
Is it possible?
Did you check for a wrong USB pullup ?
Chinese clones are known for using 10k USB pullup instead of 1.5k

/Bingo

Re: Serial 3 is not declared

Posted: Fri Dec 27, 2019 8:25 pm
by avip
Yes, I added a resistor in parallel of 1.8K.
Win10 detected the USB but claimed it is malfunction.
I tried to pull boot1 switch and the DFU was detected but I was not sure how to continue to get a bootloader via USB that will enable 4 UARTS
Is there software UART that can be added to Blue Pill?

Re: Serial 3 is not declared

Posted: Sat Dec 28, 2019 12:19 am
by ag123
did you use the correct variant?

assuming that you are using libmaple core, the board should be generic_stm32f103c
https://github.com/rogerclarkmelbourne/ ... oard.h#L42

and that board don't have a (usb) boot loader, you need a usb-uart or st-link v2 dongle
viewtopic.php?f=59&p=152&sid=ee3afc1dc2 ... d7e99#p150

if you are not familiar with stm32 mcus, start with a nucleo or discovery board from ST
https://www.st.com/en/evaluation-tools/ ... oards.html
https://www.st.com/en/evaluation-tools/ ... -kits.html

and use the official core (there are many nucleo boards you can choose, review the boards on github)
https://github.com/stm32duino/Arduino_Core_STM32

the official boards are good quality, well designed and made and you get a real stm32 mcu and they often come with peripherals st-link built-in etc

some of the (cheap) 'pill' boards offered in the wild (e.g. ebay, aliexpress etc) recently are shipped with 'clones' non-stm32 chips so you may not know if after all you are using a stm32 after all