Maker Pro
Arduino

How to program STM32F103C8T6 with ArduinoIDE?

November 15, 2021 by 冯鸣
Share
banner

In this article, I will show you how to set up STM32 using Arduino IDE and show you how to program

Software

1 STM32F103C8T6

How to program STM32F103C8T6 with ArduinoIDE

The STM32F103C8T6 board-also known as Blue Pill-is the development board M3 microcontroller of ARM Cortex. It looks very similar to Arduino Nano, but it contains more functions.

STM32 overview "Blue Pill"

If you look at this $2 microcontroller, the first thing you see is its jumper pins, which are used to use the default USART bootloader. There is also a micro USB port on the board, but unfortunately it cannot be used for programming because it does not have an associated bootloader.

Compared with the official Arduino boards, these boards are very cheap and the hardware is open source. In addition to the microcontroller, the board can also accommodate two crystal oscillators-an 8MHz crystal and a 32KHz crystal-which can be used to drive the internal RTC (Real Time Clock). Therefore, the MCU can work in deep sleep mode, which is very suitable for battery-powered applications.

To program the board, we need to use a simple USB to UART converter, and then we can program it directly from the computer via USB.PIC01

STM32 pinout

Required materials

STM32 F103C8T6

USB to UART converter (FTDI)

Jumper

Breadboard

Arduino IDE

Wiring project

Connect the circuit boards according to the connections shown in the Fritzing diagram below and connect them to the computer.PIC02

Fritzing diagram

Use the build settings with jumpers in place.

Connect the jumper as shown in the figure below, set the circuit board to DFU mode (device firmware upgrade), and then press the "reset" button.PIC03 04

Set up STM32 on Arduino IDE

Open the Arduino IDE and select preferences.PIC05

Click the "Other Board URL" option and add this URL after the comma:PIC06. 07

http://dan.drown.org/stm32duino/package_STM32duino_index.json

Then click Tools→Boards→Board Manager. PIC08

After performing the above steps, you can see STM32 in the board list. Now select STM32F103C. PIC09

Because we use the UART module to upload code, we choose Upload Method as Serial. PIC10

Select Blink sketch from the example. PIC11

Use "PC13" to change the LED pin number, as shown in the screenshot below. This is the name of the built-in LED in the circuit board.PIC12

Project source code

void setup() {

// change pin PC13

pinMode(PC13, OUTPUT);

}

//infinite loop

void loop() {

digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level)

delay(1000); // wait for a second

digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW

delay(1000); // wait for a second

}

Upload the code to the Arduino IDE

Upload the code now. PIC13

Uploaded successfully!

in conclusion

If the program has been uploaded successfully, you should see the green LED flashing at 1 second intervals. You can also use this program to increase or decrease the delay of the LED lights.

After uploading the program, you should change the jumper back to the normal mode so that the uploaded program will automatically start to execute when the circuit board is turned on next time.

图片1.png

PIC01

// Your code here
图片2.png

PIC02

图片3.png

PIC03

图片4.png

PIC04

图片5.png

PIC05

图片6.png

PIC06

图片7.png

PIC07

图片8.png

PIC08

图片9.png

PIC09

图片10.png

PIC10

图片11.png

PIC11

图片12.png

PIC12

图片13.png

PIC13

Author

Related Content

Comments


You May Also Like