Professional Documents
Culture Documents
Getting STM32
Getting STM32
000
EMBEDDED (HTTPS://CIRCUITDIGEST.COM/EMBEDDED)
Getting Started with STM32 Development Board (STM32F103C8T6) using Arduino IDE
Arduino would have been the rst board for many hobbyists (including me) and engineers out there when they
started with electronics. However, as we start building more and dig deep we would soon realise that Arduino is
not industry ready and its 8-bit CPU with a ridiculously slow clock, it does not give you enough juice for your
projects. Hopefully though, we have the new STM32F103C8T6 STM32 Development Boards (Blue Pill) in the
market now which can easily outperform Arduino with its 32-bit CPU and ARM Cortex M3 architecture. Another
honey pot here is that we can use the same old Arduino IDE to program our STM32 Boards. So in this tutorial,
let us get started with the STM32 to know a bit of basics about this board and blink the on-board LED using
the Arduino IDE.
SPONSORED SEARCHES
Materials Required
STM32 – (BluePill) Development Board (STM32F103C8T6)
FTDI Programmer
Breadboard
Connecting wires
Laptop with Internet
These boards are extremely cheap compared to the o cial Arduino boards and also the hardware is open
source. The microcontroller on top of it is the STM32F103C8T6 from STMicroelectronics. Apart from the
Microcontroller, the board also holds two crystal oscillators, one is an 8MHz crystal, and the other is a 32 KHz
crystal, which can be used to drive the internal RTC (Real Time Clock). Because of this, the MCU can operate in
deep sleep modes making it ideal for battery operated applications.
Since the MCU works with 3.3V, the board also houses a 5V to 3.3V voltage regulator IC to power the MCU.
Even though the MCU operates at 3.3V most of its GPIO pins are 5V tolerant. The pin of the MCU are neatly
pulled out and labelled as header pins. There are also two on-board LEDs, one (red colour) is used for power
indication, and the other (green colour) is connected to the GPIO pin PC13. It also has two header pins which
can be used to toggle the MCU boot mode between programming mode and operating mode, we will learn more
about these later in this tutorial.
Now few people might be wondering why this board is called as “Blue Pill”, well seriously I do not know. May
be since the board is blue in colour and can give a boosted performance to your projects someone came up
with this name in it just stayed. This is just an assumption and I have no source to back it up.
STM32F103C8T6 Specifications
The ARM Cortex M3 STM32F103C8 Microcontroller is used in the Blue pill board. Unlike the name, “Blue Pill”
the Microcontrollers name STM32F103C8T6 has a meaning behind it.
USART Peripherals: 3
I2C Peripherals: 2
SPI Peripherals: 2
RAM: 20kB
Belajar Gampang Arduino
Tanpa Kursus
Paket belajar dan menguasai Mikrokontroler
Arduino tanpa harus kursus.
tokotronik.com
If you want to know more on technical features of the Microcontroller then you can refer to its Datasheet
(https://www.st.com/resource/en/datasheet/stm32f103c8.pdf). You might also be interested in the Reference
manual (https://www.st.com/content/ccc/resource/technical/document/reference_manual/59/b9/ba/7f
/11/af/43/d5/CD00171190.pdf/ les/CD00171190.pdf/jcr:content/translations/en.CD00171190.pdf) and the
Errata sheet (https://www.st.com/content/ccc/resource/technical/document/errata_sheet/7d/02/75/64
/17/fc/4d/fd/CD00190234.pdf/ les/CD00190234.pdf/jcr:content/translations/en.CD00190234.pdf) of the
Microcontroller as well which is also linked.
(/fullimage?i=inlineimages/u/STM32-Pin-Details_0.png)
SPONSORED SEARCHES
Unlike Arduino boards, the STM32 development board has to be manually set to programming mode using the
boot 1 and boot 0 jumper wires. The position of Boot 1 is normally not disturned. But the boot 0 jumper has to
be set as 3.3V for programming mode and set to ground for operating mode. We will learn more about it when
we upload the program on our board.
But what made this board a lot popular is its ability to be programmed with the Arduino IDE. This way people
can get started and build projects with STM32 in no-time since many will be familiar with Arduino IDE and its
easy to use programming language and readily available libraries. So in this STM32F103C8T6 Arduino IDE
tutorial we will using the Arduino IDE to get started with STM32.
Circuit Diagram
To program the STM32 Blue Pill board directly from Arduino IDE we need to use a Serial FTDI board. This board
is connected to the Rx and Tx pin of the STM32 as shown below.
(/fullimage?i=circuitdiagram_mic/Circuit-Diagram-for-Blinking-LED-using-STM32.png)
The Vcc pin of the FTDI board is connected to the STM32 5V pin of power 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. Where the A9 is the Tx pin of STM32 MCU and the A10 is Rx pin.
Step 1:- If you have not yet installed the Arduino IDE, download and install it from this link
(https://www.arduino.cc/en/Main/Software). Make sure you select your correct operating system.
Step 2:- After Installing the Arduino IDE open and download the required packages for the STM32 board. Thi
can be done by selecting File -> Preferences.
Step 3:- Clicking on Preferences will open the below shown dialog box. In the additional Boards Manager URL
text box paste the below link
http://dan.drown.org/stm32duino/package_STM32duino_index.json (http://dan.drown.org/stm32duino
/package_STM32duino_index.json)
Step 4:- Now go to Tool -> Boards -> Board Manager. This will open the Boards manager dialog box, search for
“STM32F1” and install the package that appears.
Step 5:- After the package, installation is completed. Go to Tools and scroll down to nd the Generic
STM32F103C series as shown below. Then make sure the variant is 64kFlah type, CPU speed is 72MHz and
change the upload method to Serial.
Step 6:- Now, connect your FTDI board to the computer and check to which COM port the FTDI board is
connected to using device manager. Then, select the same port number in Tools->Port
Step 7:- After all the changes are made, check the bottom right corner of the Arduino IDE and you should notice
the following setting being set. My FTDI board is connected to COM7 but yours might differ
Now the Arduino IDE is ready to program the STM 32 Blue Pill Development Boards.
In the example program that opens, we have to make a small change. By default the program will be written for
PB1 but on our board the on-board LED is connected to PC13 so replace all PB1 with PC13 and we are good to
proceed. The complete example program which is modi ed can also be found at the bottom of this page.
The code inside the loop function alone is shown below, where we can notice that the PC13 pin is kept HIGH
(on) for 1000 millisecond and then turned LOW (off) for another 1000 millisecond and this is done for in nite
times since it is in loop function. Thus the LED appears to be blinking with an interval of 1000 millisecond.
As told earlier the STM32 Board has to be put into programming mode before uploading any program, to do
this put the boot 0 jumper in the lower position. The Jumper position for Programming mode and Operating
mode are shown below.
Now, to upload the program make sure the boot 0 jumper is in programming mode as shown above and then
press the Reset button. As soon as you press the reset button the board will enter into programming mode and
the green LED will be turned off, this indicates that the board is ready for upload. Press the upload button on
the Arduino IDE and your program should get compiled and uploaded. If everything has worked as expected
then you should see the following on yor Arduino IDE console.
Note: Sometimes the Arduino IDE will show done Uploading even if the program was not uploaded successfully.
So drag open your console to check the write address percentage (orange colour text) to make sure the Upload
has been done successfully.
After uploading the program the boot 0 should be changed back to operating mode so that next time when the
Board is powered the uploaded program starts to get executed automatically. The programming mode and
operating mode positions are shown in the above image.
Hope you understood the tutorial and found it useful to get started with STM32 Board. If you have any problem
leave them in the comment section, also tell me what projects we should try with this STM32 board.
Code
/*
circuitdigest.com
Sample STM32 Blink Program for Blue Pill board
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin PC13 as an output.
pinMode(PC13, OUTPUT);
}
Video
TAGS EMBEDDED (/TAGS/EMBEDDED) STM32 (/TAGS/STM32)
RELATED CONTENT
(/news/fpga-family-enhances-security-hardware- (/news/32-bit-mcus-with-dedicated-hardware-
root-trust-capabilities) accelerator-for-servo-control-in-industrial-robots)
FPGA Family Enhances Security with Hardware 32-bit MCUs with dedicated hardware accelerator
Root-of-Trust Capabilities (/news/fpga-family- for Servo Control in Industrial Robots (/news
enhances-security-hardware-root-trust- /32-bit-mcus-with-dedicated-hardware-
capabilities) accelerator-for-servo-control-in-industrial-robots)
(/tutorial/what-is-fpga-introduction- (/news/nxp-lpc55s6x-arm-cortex-m33-based-
and-programming-tools) mcus-for-secure-edge-applications)
Introduction to FPGA and It's Programming Tools NXP’s LPC55S6x Arm Cortex-M33-based MCUs for
(/tutorial/what-is-fpga-introduction- Secure Edge Applications (/news/nxp-lpc55s6x-
and-programming-tools) arm-cortex-m33-based-mcus-for-secure-
edge-applications)
(/news/wireless-platform-enables- (/news/nxp-imx-8m-mini-processors-for-edge-
next-generation-connected-products- computing-and-machine-learning)
advancing-iot) NXP i.MX 8M Mini Processors for Edge Computing
Wireless Platform Enables Next-Generation and Machine Learning (/news/nxp-imx-8m-mini-
Connected Products Advancing the IoT (/news processors-for-edge-computing-and-machine-
/wireless-platform-enables-next-generation- learning)
connected-products-advancing-iot)
(/news/touch-free-ui-solutions-capacitive-touch-
key-microcontroller-for-2d-3d-gesture-control)
Touch-Free UI Solutions with capacitive Touch-Key
Microcontroller for 2D/3D Gesture Control (/news
/touch-free-ui-solutions-capacitive-touch-
key-microcontroller-for-2d-3d-gesture-control)
(/news/nxp-nxh3670-wireless-gaming-
headphone-solution-high-performance-audio-
streaming)
NXP’s NXH3670 Wireless Gaming Headphone
Solution for High-Performance Audio Streaming
(/news/nxp-nxh3670-wireless-gaming-
headphone-solution-high-performance-audio-
streaming)
Email Address *
Name
Country
United States of America
Subscribe
PREVIOUS POST
How to Setup Webserver on Raspberry Pi and Host a WordPress Website
(https://circuitdigest.com/microcontroller-projects/how-to-setup-webserver-on-raspberry-
pi-and-host-a-wordpress-website)
NEXT POST
Interfacing 16X2 LCD with ESP32 using I2C (https://circuitdigest.com/microcontroller-
projects/interfacing-16x2-lcd-with-esp32-using-i2c)
COMMENTS
Wainer (/users/wainer)
(/users/wainer) Oct 29, 2018
Hello!
Log in (/user/login?destination=node/2414%23comment-form) or register (/user
/register?destination=node/2414%23comment-form) to post comments
You guys should try to use inertial sensors with this stm32 and arduino. I think its a
very good project to develop.
Sohotcall (/users/sohotcall)
(/users/sohotcall) Feb 22, 2019
“
Log in (/user/login?destination=node/2414%23comment-form) or register (/user
”
/register?destination=node/2414%23comment-form) to post comments
"Now few people might be wondering why this board is called as
“Blue Pill”, well seriously I do not know. May be since the board
is blue in colour and can give a boosted performance to your
projects someone came up with this name in it just stayed. This is
just an assumption and I have no source to back it up."
So someone name them with name of the pills from The Matrix (movie): Red Pill
and Blue Pill.
TI TRAINING VIDEOS
Solutions for Fast Charging Electric Vehicle Supply Equipment (EVSE) Design
(https://ad.doubleclick.net/ddm/clk/440294741;243805998;s?https://training.ti.com
/solutions-fast-charging-electric-vehicle-supply-equipment-evse-design?cu=1127787&
HQS=corp-otpp-null-training_videos-asset-tr-CircuitDigest-in&DCM=yes &https%3A%2F
%2Ftraining.ti.com%2Fsolutions-fast-charging-electric-vehicle-supply-equipment-
evse-design%3Fcu=1127787&HQS=corp-otpp-null-training_videos-asset-tr-CircuitDigest-
in&DCM=yes_)
EV Charging station - Introduction (https://ad.doubleclick.net/ddm/clk
/440294741;243805998;s?https://training.ti.com/introduction-ev-charging-stations-
piles?HQS=corp-otpp-null-training_videos-asset-tr-CircuitDigest-in&DCM=yes &https
%3A%2F%2Ftraining.ti.com%2Fintroduction-ev-charging-stations-piles%3FHQS=corp-
otpp-null-training_videos-asset-tr-CircuitDigest-in&DCM=yes_)
High Voltage Solutions in HEV/EV Part I - On Board Chargers and Charging Stations
(https://ad.doubleclick.net/ddm/clk/440294741;243805998;s?https://training.ti.com/high-
voltage-solutions-hevev-part-i-board-chargers-and-charging-stations?HQS=corp-otpp-null-
training_videos-asset-tr-CircuitDigest-in&DCM=yes &https%3A%2F
%2Ftraining.ti.com%2Fhigh-voltage-solutions-hevev-part-i-board-chargers-and-charging-
stations%3FHQS=corp-otpp-null-training_videos-asset-tr-CircuitDigest-in&DCM=yes_)
High Voltage Solutions in HEV/EV Part II - DC/DC Converters and Traction Inverters
(https://ad.doubleclick.net/ddm/clk/440294741;243805998;s?https://training.ti.com/high-
voltage-solutions-hevev-part-ii-dcdc-converters-and-traction-inverters?cu=1134585&
HQS=corp-otpp-null-training_videos-asset-tr-CircuitDigest-in&DCM=yes &https%3A%2F
%2Ftraining.ti.com%2Fhigh-voltage-solutions-hevev-part-ii-dcdc-converters-and-traction-
inverters%3Fcu=1134585&HQS=corp-otpp-null-training_videos-asset-tr-CircuitDigest-
in&DCM=yes_)
How to Design Multi-kW DC/DC Converters for Electric Vehicles (EVs) - EV System
Overview (https://ad.doubleclick.net/ddm/clk/440294741;243805998;s?https:
//training.ti.com/how-design-multi-kw-dcdc-converters-electric-vehicles-evs-ev-system-
overview?cu=1128387&HQS=corp-otpp-null-training_videos-asset-tr-CircuitDigest-
in&DCM=yes &https%3A%2F%2Ftraining.ti.com%2Fhow-design-multi-kw-dcdc-converters-
electric-vehicles-evs-ev-system-overview%3Fcu=1128387&HQS=corp-otpp-null-
training_videos-asset-tr-CircuitDigest-in&DCM=yes_)
LATEST POSTS
(/microcontroller-projects
/sending-sensor-data-to-android-phone-using-arduino-nrf24l01-over-bluetooth-ble)
Sending Sensor Data to Android Phone using Arduino and NRF24L01 over Bluetooth (BLE)
(/microcontroller-projects/sending-sensor-data-to-android-phone-using-arduino-nrf24l01-
over-bluetooth-ble)
(/news/12-bit-adc-meets-
most-demanding-requirements-of-tomorrows-test-and-measurement-and-defense-applications)
12-bit ADC meets the most demanding requirements of tomorrow's test and measurement, and
defense applications (/news/12-bit-adc-meets-most-demanding-requirements-of-tomorrows-
test-and-measurement-and-defense-applications)
(/article/what-is-lidar-
and-how-does-lidar-works)
What is LiDAR and How does it Work (/article/what-is-lidar-and-how-does-lidar-works)
(/microcontroller-projects
/iot-based-biometric-attendance-system-using-arduino-and-thingsboard)
IoT Based Biometric Attendance system using Arduino and Thingsboard (/microcontroller-projects
/iot-based-biometric-attendance-system-using-arduino-and-thingsboard)
(/news/free-inventory-
management-tool-from-mouser-electronics-simpli es-parts-management-and-ordering)
Free Inventory Management Tool from Mouser Electronics Simpli es Parts Management and
Ordering (/news/free-inventory-management-tool-from-mouser-electronics-simpli es-parts-
management-and-ordering)
(/news/2-ghz-3-ghz-and-5-
ghz-dual-band-omni-antennas-reduces-tower-rental-and-installation-costs)
2 GHz, 3 GHz, and 5 GHz Dual Band Omni Antennas reduces tower rental and installation costs
(/news/2-ghz-3-ghz-and-5-ghz-dual-band-omni-antennas-reduces-tower-rental-and-installation-costs)
12-bit ADC meets the most demanding requirements of tomorrow's test and measurement,
and defense applications (/news/12-bit-adc-meets-most-demanding-requirements-
of-tomorrows-test-and-measurement-and-defense-applications)
(/news
/12-bit-
adc-meets-
most-demanding-
requirements-
of-tomorrows-
test-and-
measurement-
and-defense-
applications)
Free Inventory Management Tool from Mouser Electronics Simpli es Parts Management and
Ordering (/news/free-inventory-management-tool-from-mouser-electronics-simpli es-parts-
management-and-ordering)
(/news/free-
inventory-
management-
tool-from-
mouser-
electronics-
simpli es-
parts-
management-
and-ordering)
2 GHz, 3 GHz, and 5 GHz Dual Band Omni Antennas reduces tower rental and installation
costs (/news/2-ghz-3-ghz-and-5-ghz-dual-band-omni-antennas-reduces-tower-rental-
and-installation-costs)
(/news/2-ghz-
3-ghz-and-5-
ghz-dual-
band-omni-
antennas-
reduces-
tower-rental-
and-installation-
costs)
(/news
/st-collaborates-
with-gaia-
advance-
clean-india-
mission)
Maxim DS28E39 and DS28E84 DeepCover Authenticators for Medical Device Protection
(/news/maxim-ds28e39-and-ds28e84-deepcover-authenticators-for-medical-device-
protection)
(/news
/maxim-
ds28e39-
and-ds28e84-
deepcover-
authenticators-
for-medical-
device-
protection)
ThingSpeak não mostra dado (IoT Based Patient Monitoring System using ESP8266 and Arduino)
(/forums/internet-things/thingspeak-n%C3%A3o-mostra-dado-iot-based-patient-monitoring-system-
using-esp8266-and-arduino)
(/users/lena-2) lena (/users/lena-2) Replies: 2
where the global and local variables are saved in memory in C (/forums/general/where-global-
and-local-variables-are-saved-memory-c)
(/users/sophie) sophie (/users/sophie) Replies: 0
Password *
Log in
Connect with us on social media and stay updated with latest news, articles and projects!
(https://www.linkedin.com
/company
(https://www.youtube.com
(https://www.facebook.com
(https://twitter.com
/channel
(https://www.instagram.com
(https://www.pinterest.com
/circuit-
/circuitdigest/)
/CircuitDigest)
/UCy3CUAIYgZdAOG9k3IPdLmw)
/circuit_digest/)
/circuitdigest/)
digest/)
CATEGORIES
POPULAR
CALCULATORS (HTTPS://CIRCUITDIGEST.COM/CALCULATORS)
NEWSLETTER
Subscribe