You are on page 1of 6

instructables

Getting Started With Stm32f103c8 With Mbed+STLink V2

by XavierJ4

Stm32f103c8 aka blue pill is a cheap ARM cortex m3 based processor which u can easily get by less than 2$ from
sites like Aliexpress.This instructable is an intro them ARM mbed platform.

Hardware required

STM32f03 (STM32f103c8 ,Will work with any stm32f103 series)

ST Link V2 -> Cheap programmer less than 2$

Step 1: Getting Started

If you're like me and coming from Arduino and moving via the SWD debugging interface.
up to ARM and heard of the mbed platform, but when
u visit the mbed website you realize that the website Software required
only directly supports mbed enabled development
boards and our stm32f103c8 or blue pill is nowhere to Mbed online compiler(web browser)
be seen.:(.But don't worry the MCU is fully (Almost)
compatible with another mbed enabled dev board ST-link Utility->http://www.st.com/en/embedded-
called NUCLEO-F103RB.You will also require an app software/stsw-link004.html (Login Required)
called stink utility which is used to program the MCU

Getting Started With Stm32f103c8 With Mbed+STLink V2: Page 1


Step 2: Setting Up Mbed

Now to setup the online compiler we have to first Now click on STMicroelectronics on the target
make an account in mbed go to vendor, now you will see the NUCLEO-F103RB listed
select and add to compiler
http://developer.mbed.org
Upon adding to the compiler the compiler, you will be
Make an account and after the registration is presented with a list of example programs.Great:)
complete you will automatically be taken to the online
compiler Select Blinky LED Hello world (or any other program
if you know what your doing)
Now to add a dev board click on import a program
upon which you will be asked to add a platform and Congratulations you have set up mbed compiler
will be directed to the mbed board's page
(https://developer.mbed.org/platforms/)

Getting Started With Stm32f103c8 With Mbed+STLink V2: Page 2


Step 3: Programing LED Blink

Now to be able to use mbed online compiler to write DigitalOut myled(LED1);


programs for youl need a library
int main()
https://developer.mbed.org/users/hudakz/code/mbed-
... {

Click on import into compiler to add to your mbed while(1)


compiler
{
Now select the path to your program and select
import myled = 1; // LED is OFF

Now you can see the library files in your workspace wait(0.2); // 200 ms

Select main.cpp and add the library by myled = 0; // LED is ON

adding wait(1.0); // 1 sec

#include "stm32f103c8t6.h" }

so the program should look like this }

#include "stm32f103c8t6.h" //Make sure this comes Then click compile and cross your fingers:)
first i have no idea why(someone smarter than me
can tell me) This will download the binary file which we will upload
to our MCU
#include "mbed.h"

Getting Started With Stm32f103c8 With Mbed+STLink V2: Page 3


Getting Started With Stm32f103c8 With Mbed+STLink V2: Page 4
Step 4: Loading the Program to the MCU

Before you can load programs you need to install the And select Target-Connect
stink drivers
It will show the data present in the MCU (in
go to http://www.st.com/en/embedded-software/stsw- hexadecimal format) we are not going to do anything
link0... with that now

Download and install the drivers open the binary file file-open

and in the device manager you will see that it shows Now select target-program
up as
and select start
STMicroelectronics STLink Dongle
Now the program will be flashed and the led wil start
This means you have successfully installed the stlink blinking......:):D
drivers and are ready to go
If you have trouble connecting to the target make sure
Now wire the stm32 board with st link v2 in the drivers
following manner
you can also try by connecting in"connect under
Connect board and ST link in following manner. reset" mode in setting and erasing the chip selecting
STLINK------>STM32 Board erase chip while holding down the reset buttom in
stm32 board
(Reset)-----------(R)
Refernces
(3.3v)-------------(3.3v)
https://developer.mbed.org/users/hudakz/code/STM3
(SWCLK)--------(DCLK) 2...

(SWDIO)---------(DIO) Check out the above link for more info

(GND)-------------(GND) This is my first instructable and i would love to hear


some constructive critsism from you guys in the
Make sure to check the pinout of the board and the comments below, I myself got into mbed platfrom
ST Link your using quite recently and i will try to put more instructables
taking this further like offline compiling ,STM32cube
Now open ST Link Utility i mentioned earlier etc

Getting Started With Stm32f103c8 With Mbed+STLink V2: Page 5


Getting Started With Stm32f103c8 With Mbed+STLink V2: Page 6

You might also like