Tutorial: mbed-Part 1

Overview

In this tutorial, you will use ‘mbed’ online compiler to handle several peripherals of MCU (ARM-Cortex M4). Using the given platform, you will perform some tasks about GPIO, timer and interrupt.

The objectives of this lab are

  • Practice to use ‘mbed’ library in online compiler.

  • Understand digital in/out peripheral in MCU.

  • Understand timer and interrupt function of MCU.

  • Handle GPIO, timer and interrupt using ‘mbed’ library.

Hardware

Tutorial

Creating account

Open https://www.mbed.com/en/

Create new account

If you already have an account, then click on 'Compiler'

****

Creating New Program

On menu bar, **** select New>Create New Program.

For the first project, it can ask for ‘add new platform’.

****

Hardware Setting

For the Platform, select your MCU board.

  1. For NUCLEO-F411RE:

  • Click ‘Add Platform’ > Search for ‘NUCLEO-F411RE’ board

  • Click ‘Add to your Mbed Compiler’ and ‘Open Mbed Complier

2. For NUCLEO-F401RE:

  • Click ‘Add Platform’ > Search for ‘NUCLEO-F401RE’ board

  • Click ‘Add to your Mbed Compiler’ and ‘Open Mbed Complier

New program

Set the Program Name as: ‘Tutorial1_GPIO_LED’.

Right-Click on the Program name in Program Workspace. Then, create new file. Name the source file as ‘main.cpp’.

Import 'mbed' Library

Right-Click on the Program name in Program Workspace. Select Import Library.

On the Import Wizard Window > Libraries tab : Search 'mbed'. Choose the mbed created by 'mbed_official'.

Compile

Copy and paste the following source code on ‘main.cpp’.

#include "mbed.h"

DigitalOut led(LED1);

int main() {
    while(1) {
    led = 1;
    }
}

Then, compile the program by clicking on ‘Compile’ button.

If the compilation is successful, the binary file of the project "**.bin" will be created and downloaded on your computer.

Import to MCU

Connect the MCU board to your PC via USB cable and check if a new memory drive of “NODE_F401RE (E:)” is created in your computer.

To load the binary program onto the MCU, copy the downloaded binary file to the drive “NODE_F401RE (E:)”.

If the program is loaded successfully then LED(LD1) will be green light.

Click reset button on MCU if nothing happens'

****

****

****

Last updated