Serial 3 is not declared

Post here first, or if you can't find a relevant section!
Post Reply
avip
Posts: 4
Joined: Tue Dec 24, 2019 8:22 am

Serial 3 is not declared

Post 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?
fpiSTM
Posts: 1836
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 102
Location: Le Mans
Contact:

Re: Serial 3 is not declared

Post by fpiSTM »

Which core you used and how?
To get support please be more precise ;)
avip
Posts: 4
Joined: Tue Dec 24, 2019 8:22 am

Re: Serial 3 is not declared

Post 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.
tomtom381
Posts: 4
Joined: Mon Dec 23, 2019 11:18 pm

Re: Serial 3 is not declared

Post 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?
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

Re: Serial 3 is not declared

Post 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.
fredbox
Posts: 125
Joined: Thu Dec 19, 2019 3:05 am
Answers: 2

Re: Serial 3 is not declared

Post 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.
avip
Posts: 4
Joined: Tue Dec 24, 2019 8:22 am

Re: Serial 3 is not declared

Post 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?
Bingo600
Posts: 87
Joined: Sat Dec 21, 2019 3:56 pm

Re: Serial 3 is not declared

Post 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
avip
Posts: 4
Joined: Tue Dec 24, 2019 8:22 am

Re: Serial 3 is not declared

Post 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?
ag123
Posts: 1797
Joined: Thu Dec 19, 2019 5:30 am
Answers: 28

Re: Serial 3 is not declared

Post 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
Post Reply

Return to “General discussion”