- STM32F103C836 Blue Pill
- UC00C (CH340) USB to UART Converter
- USB Micro B Cable
- Male to Male Jumper Wire
STEP 1: Preparing Arduino IDE Setup.
Download and install Arduino IDE into your computer.
Open the Arduino IDE.
First, you need to download the library for STM32. Go to Tools > Board > Boards Manager. Then, simply search for “Arduino SAM Boards (32-bits ARM Cortex-M3)” and install it.
STEP 2: Download the Arduino STM32-master.
Then you need to download the driver that can support STM32 board in Arduino IDE. The latest driver was modified by Roger Clark. Download the com drivers here.
Unzip the downloaded file. Then, go to the Arduino installation folder. It is usually at C:\Program files(x86)\Arduino.
Now, go to the hardware folder of the Arduino file. In the hardware folder, drag the “Arduino_STM32-master” from the ZIP to the hardware folder and rename it to Arduino_STM32.
The Arduino IDE now can detect the STM32 board.
STEP 3: Preparing the hardware parts.
For the hardware parts, connect the FTDI programmer to the STM32F103C8T6 Blue Pill.
In this tutorial, UC00C (CH340) USB to UART Converter is used for the FTDI programmer.
The VCC pin of the FTDI board is connected to the STM32 5V pin to supply the board. The ground is connected to the ground of STM32. The Rx and Tx pin of the FTDI board is connected to the A9 and A10 pin of the STM32 respectively.
Please note that STM32 is a 3.3V microcontroller. Despite the fact that some pins are 5V tolerant, connecting to a 5V power supply will definitely damage it.
Insert the USB cable from the computer to the FTDI programmer and the LED of the STM32 will start to flash. This is the uploaded program by the manufacturer.
STEP 4: Running the code.
Open the Arduino IDE. Go to Tools > Board > Generic STM32F103C series.
For Variant, select the 64k version. Then, go to CPU speed and choose 72MHz while for the upload method, select the Serial.
Select the COM port that is connected to the FTDI programmer.
Next, go to File > Examples > A_STM32_Examples > Digital. Find the Blink sketch and open it.
Based on the pinout diagram above, the LED of STM32 board is connected to pin C13.
In the example program that opens, you have to make a small change. By default, the program will be written for PB1 but the onboard LED is connected to PC13, so replace all PB1 with PC13 and you are good to proceed.
The PC13 pin is kept HIGH (on) for 1000 millisecond and then turned LOW (off) for another 1000 millisecond and this is done for infinite times since it is in loop function. Thus the LED appears to be blinking with an interval of 1000 millisecond.
STEP 5: Final.
Make sure the boot 0 jumper pin on the board is set to 1 (programming mode) before uploading the program. Once the STM32 is flashed this pin can be changed back to initial position (operating mode).
Press the RESET button and the microcontroller is now in program mode. Upload the code in the Arduino IDE and the LED will start to blink.
If the Program has been uploaded successfully then you should see the Red LED blinking at a 1 second interval. You can also fiddle around with the program to increase or decrease the delay.
To upload another program, just press the RESET button on the board and the microcontroller is in program mode again.
Hope you understood the tutorial and found it useful to get started with STM32 Board. If you have any problems, leave them in the comment section below.
Credits goes to following references:
- https://www.youtube.com/watch?v=MLEQk73zJoU, great explanations by Joop Brokking in getting started with the STM32 microcontroller – STM32F10C836 via Arduino.
- https://circuitdigest.com/microcontroller-projects/programming-stm32f103c8-board-using-usb-port, very comprehensive steps to use STM32 (Blue Pill) without external hardware to upload and test programs.
- https://github.com/rogerclarkmelbourne/Arduino_STM32, the Arduino_STM32 project of Roger Clark on GitHub.
- https://www.arduino.cc/en/software, the official page to download Arduino IDE.
- https://create.arduino.cc/projecthub/akarsh98/using-a-stm32-like-an-arduino-tutorial-stm32f103c8-1073cb, comparison between STM32 and other types of Arduino.
- https://www.electronicshub.org/getting-started-with-stm32f103c8t6-blue-pill/, deep explanations about the STM32 Blue Pill.