Using STM32F103C8T6 "Blue Pill" Development Board with Arduino IDE.
I have recently bought a STM32F103C8T6 "Blue Pill" from Cytron Technologies for around $USD 3.21
The board has the following specifications:
MCU: STM32F103C8T6
Core: Single Core, Arm Cortex-M3
Operating Voltage: 3.3VDC
Max. Clock Speed: 72MHz
FLASH: 64KB
SRAM: 20KB
HSI: 8MHz
LSI: 40KHz
HSE: 8MHz
LSE: 32.768kHz
GPIO Pins – 32 with external interrupt capability
Timers – 3 16-bit Timers, 1 16-bit PWM Timer
PWM Pins – 15
Analog – 10 Channels of 12-bit ADC
I2C – 2 I2C Peripherals
USART – 3 USART Peripherals with hardware control
SPI – 2 SPI Peripherals
Other Peripherals – USB 2.0 Full Speed, CAN 2.0B
Power Sources
Any +3.3V pin (+3.3V)
Any +5V pin (+5V)
USB connector (+5V)
PCB Size: (w x l)23mm x 53mm
There is however a problem with many "Blue Pill" boards that the Resistor on the USB d+ line is a wrong value ( 4k7 or 10k where it should be 1k5 of 1k8). This error does not prevent the board from functioning, but it prevents you from uploading code with the usb port!
If you can rework a smd pcb it is easy to just replace the resistor with the correct value, but I am not quite setup for smd manufacture at the moment, and do not have smd components available anyway Maybe time to start getting into that ...
You can however use a USB to UART converter to upload code to the board. I have used Cytron's UC00C, which has a selector switch to select the uart voltage between 5v and 3v3.
My connections are as follows
UART PIN "Blue Pill" Pin
Vcc ( Red) 5v or 3v3, depending on what you selected
on the UART
Gnd (Blue) and GND Pin
TxD (Yellow) Pin A10 (Rxd)
RxD(Green) Pin A09 (TxD)
Be sure that you dont connect 5v to a 3v3 pin, as you will damage the development board !
Next is to configure the Arduino IDE to allow us to write code and upload it to the STM32
Open the IDE and Click on File -> Preferences
Paste the following url
http://dan.drown.org/stm32duino/package_STM32duino_index.json
into the additional board manager url list and click on OK
Then Click on Tools -> Board: -> Boards Manager
Type STM32 and select STM32F1xx/GD32F1xx by stm32duino
Click on install and when that is done, click on close
Close and restart the Arduino IDE.
You are now ready to program the "Blue Pill" board with the Arduino IDE
To test it, Click on File -> Examples -> A_STM32_Examples->Digital->Blink
Please change PB1 to PC13 in the code, as our builtin led is connected to pin 13 on port c ( other boards may be different )
Click on Tools->Board: and select Generic-STM32F103C Series
Click on Tools->Upload Method and Select "Serial"
Change the jumpers on the "Blue Pill" as in the photograph to enable us to upload to system memory.
Plug the usb cable into the usart and computer, the red power light will light up.
Click Tools->Port and select the port of the USB to UART converter.
Now you may click on upload and if you are lucky the led will start flashing once a second, as programmed ...
Change back the jumpers to their original position to have the board automatically run your code at startup
On Linux ( Ubuntu 18.04 ) I was not so lucky to have it work immediately, and after some additional reading and testing, found that there is some issue with the CH340 USB UART Chip and Linux CH340 Driver. I have a similar issue with ESP32 Wroom Modules..
The workaround is easy, but a bit of a pain. Press and hold down the reset button on the "Blue Pill"
Click and Hold Upload button in the IDE, Release Reset Button and Then Upload .. All should be well ...
I hope this helps someone. Please note that this may not be an issue with Windows, but i wont know as my OS of choice is Linux.
By the way, there is an Arduino bootloader available to enable you to upload software to the "Blue Pill" via the USB port. I have not been successful in getting it to work without changing that resistor yet, but will keep trying and post again when I have a solution
Update : I found a fix to allow uploading through native USB -> click Here to learn how to do that.