💾
EC
  • Introduction
  • EC Course
    • Syllabus
    • Preparation for EC
    • Tutorial
      • Tutorial: arduino-stm32
        • Tutorial: arduino-stm32 Installation
        • Tutorial: arduino-stm32 Part1
        • Tutorial: arduino-stm32 Part2
      • Tutorial: MDK uVision
        • Tutorial: Installing MDK uVision
        • Tutorial: Create a Project with uVision
        • Tutorial: Adding library header in uVision
        • Tutorial: Re-using Project Configuration
        • Debugging in uVision
      • Tutorial: PlatformIO in CLion
      • Tutorial: PlatformIO in VSCode
      • Tutorial: Repository Management
      • Tutorial: Managing library header files
      • Tutorial: PinName Configuration
      • Tutorial: Bitwise Macro
      • Tutorial: Custom initialization
      • Tutorial: Documentation
      • Tutorial: Creating Application API
      • Tutorial: 7-Segment Display
      • Tutorial: DC motor driver connection
      • Tutorial: USART with TeraTerm
      • Tutorial: Finite State Machine programming
      • Tutorial: Bluetooth
      • Tutorial: Zigbee with Nucleo board
    • LAB
      • LAB Report Template
      • LAB: Smart mini-fan with STM32-duino
      • LAB: Portable Fan with mbed
      • LAB: GPIO Digital InOut
      • LAB: GPIO Digital InOut 7-segment
      • LAB: EXTI & SysTick
      • LAB: Timer & PWM
      • LAB: Stepper Motor
      • LAB: Input Capture - Ultrasonic
      • LAB: USART - LED, Bluetooth
      • LAB: ADC - IR reflective sensor
      • LAB: Line Tracing RC Car
    • Sample code
      • Code Templates
    • Hardware
      • Nucleo-F411RE
      • LAB Hardware
        • Electronic Chips
        • HUINS Embedded Kit
    • Projects
      • Line Tracing Car Project
      • Design Project
        • Past Projects
      • Project Grading Criteria
    • Study Resource for MCU
      • Hexa-Decimal Table
      • Bitwise Op for Register
      • System Clock
      • Timer
      • USART
      • ADC
  • STM32 M4 Programming
    • Documentation
      • C++ API Docs
    • Firmware Library
      • PinName Configuration
      • GPIO Digital
      • RCC
      • EXTI_SysTick
      • TIMER
      • USART
    • Troubleshooting
    • mbed for STM32
      • Tutorial: mbed-Part 1
      • Tutorial: mbed - Part 2
      • Tutorial: mbed - Part 3
      • Using mbed API on uVision
    • mbed OS
  • Other Programming
    • Arduino
    • Socket Programming
      • Window Socket Programming
      • Arduino WiFi
    • Cube-MX
    • Github
    • Markdown
      • Example: API documentation
    • MATLAB
  • C Programming
    • C-Programming Lessons
      • Installing Visual Studio Community
        • Visual Studio Community 2022
      • Installing VS Code(Mac/Linux)
      • Creating Header Lib
      • Pointer
      • Array
      • 2D Array
      • Structure
      • Dynamic Alloc
      • Bitwise Operation
  • Numerical Programming
    • Syllabus
    • Preparation for NP
    • Math Review
    • Tutorial
      • TA Session Video
      • Tutorial: NP Library Header Files
      • Tutorial - Sine Taylor
      • Tutorial: Passing a Function, Function callback
      • Tutorial: Nonlinear solver
      • Tutorial: Differentiation
      • Tutorial: Integration
      • Tutorial: Matrix Structure
      • Tutorial: Eigenvalue problem
      • Tutorial: ODE-IVP
      • Tutorial: Curve Fitting
      • Tutorial: Create Github Repos of NP lib
      • Tutorial: Version Control in Github
      • Tutorial: Documentation with Markdown
      • Exercise: Version Control and Documentation
    • Example: MATLAB
    • Example: NP Library
    • Assignment
      • Assignment Factorial and Power
      • Assignment: Version Control and Documentation
    • Problem Bank
Powered by GitBook
On this page
  • Overview
  • Hardware
  • Tutorial
  • Creating account
  • ****
  • Creating New Program
  • Hardware Setting
  • New program
  • Import 'mbed' Library
  • Compile
  • Import to MCU

Was this helpful?

  1. STM32 M4 Programming
  2. mbed for STM32

Tutorial: mbed-Part 1

Previousmbed for STM32NextTutorial: mbed - Part 2

Last updated 9 months ago

Was this helpful?

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

​ Figure 1. Pin configuration for NUCLEO-F411RE board (same pin configuration with NUCLE-F401Re)

Tutorial

Creating account

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'

****

****

****

Open

image-20210811204723487
add_platform
mbed_compiler
401
compile
https://www.mbed.com/en/