loading

Have STM32F103RBT6? Let's get Started.

In this tutorial we will be using free online mbed compiler to write and compile our code. Which means we dont need to install any software's. However, we do need to SignUp as mbed developer to get access to online compiler for free. We will be using mbed.h in all of our programmes (using mbed online compiler).

This Tutorial is divided into 3 easy steps:

1) Creating Developer account.

2) Blinking LED.

3) Understanding the Code

4) Compiling and Burning Code.

Step 1: Creating Developer Account

Click here , to Open this link in new tab. [https://developer.mbed.org/]

Click Green "Login or signup" button in the top right corner.

If you already have signed up, then login. If not then signup by clicking on "Sign Up" button. Click on "No, I haven't created an account beore". A form will appear below these buttons. Fill in those fields and click on Signup button.

Now, come back to first page [https://developer.mbed.org/] .

Step 2: Blinking LED

Now, that you have signed in to you mbed developer account Lets start writing code.

Click on "Platforms" button in top left corner. Scroll Down to search for "NUCLEO-F103RB". Click it.(or Click Here)

Here, you can find documentations related to NUCLEO-F103RB on this page, like Overview, Microcontrollerfeatures, Nucleo features, Nucleo pinout, Supported shields etc

Not just that, you can also find example programs to get started.

In example programs click on first "Nucleo_blink_led". Now click on "Import this Program" Button.

This will open your project in "Compiler". Enter a project name and proceed.

Now, Click on "main.cpp" to Open this file in the Compiler. That it! That the code you will need to blink LED.

Step 3: Understanding the Code

Lets try to understand this code: First line

#include "mbed.h"<br>

is just importing 'mbed.h'.

DigitalOut myled(LED1);

This line is declaring an object myled of type DigitalOut passing an argument LED1. This class is defined in mbed.h. What this line is actually doing is that its telling the controller that "'LED1 pin is as DigitalOutput Pin and I will call this pin as myled ". Note that, LED1 refrs to LED on our NUCLEO board and is defined in mbed.h.

After this the famous 'main()' function. Inside main we have a while(1) loop which means that code inside this loop will run forever, until powered off or reprogrammed.

After that

myled = 1;

yes, as obvious, this will turn our 'LED1' 'ON'. Next,

wait(0.2);

and yes, this will wait for 0.2 'SECONDS' (not miliseconds). and that was our code. :)

Step 4: Compiling and Burning Code

Now, Connect your STM32 Nucleo board to your computer. Nucleo will appear as a separate partition (Drive) in you 'My Computer'/'This PC'.

Now, Click on 'Compile' Button. (or press Ctrl + D). This will Compile your code, generate a .bin) binary file and download this file. A Save file dialog will appear (depends on your browser settings).

Now, if you want to flash this binary file onto your nucleo, just select your nucleo directory. This obviously (not only) will download .bin file to your Nucleo board but will also flash it.

Or you can just download it anywhere and drag and drop it onto 'Nucloe' directory icon in you My Computer/This PC whenever you want to flash this .bin file.

That it! Say Hi! to that Blinking LED on your STM32. :)

About This Instructable

2,228views

0favorites

License:

More by ARK4579:Getting Keil and STM32CubeMX ready STM32103: esp8266 NodeMCU ThingSpeak [using mbed.h] STM32F103: esp8266 nodeMCU Getting Started [using mbed.h] 
Add instructable to: