Tutorial: STM32F746 (STM32F7 Discovery) – how to turn on LED (controlling GPIO)

The first article from Tutorial: STM32F746 (STM32F7 Discovery) serie. I would like to describe how to turn on LED simply controlling GPIO. Why I began to write this tutorial and why I don’t want to use HAL or Standard Peripheral library.

Other tutorials with STM32F7:
Tutorial: STM32F746 (STM32F7 Discovery) – how to turn on/off LED by button
Tutorial: STM32F746 (STM32F7 Discovery) – how to turn on LED (controlling GPIO)
STM32F746 discovery and AC6 (System Workbench for STM32)
How to begin with STM32 and why – tutorial

These example codes can be used for another STM32F (STM32F407, STM32F103, STM32F427, STM32F746…) and STM32L (STM32L100, STM32L152, STM32L476…) with easy changes – typically atypic peripherals and change of clock source for peripherals – AHB, APB…

These codes will be written for STM32F746 with AC6 System Workbench for STM32 IDE by http://openstm32.org. But you can use these codes in another IDE e.g. Keil.

At first: Why I don’t want to use HAL or Standard Peripheral Library.

Codes write people and people do mistakes (sometimes errors). If you want to use HAL and in the code will be mistake, you have to check their codes and that’s not easy.

On the other side, If you will write own code, you know the code and structure of ARM and STM32. Yes, HAL or Standard Peripheral Library are very good functions and if you want to use it, do it. But this tutorial isn’t for you.

The tutorial will be written with finished example code which will be commented. If some code will be complicated, I will explain it on this tutorial.

Be careful, my codes can’t be always right (under all conditions). I hope that you will read datasheet and reference manual of specifically STM32 product.

main.h


main.c

MODERy[1:0] setting of PIN

00: PIN as input

01: PIN as output

10: Alternative function of PIN

11: Analog input

OSPEEDRy[1:0] These bits are written by software to configure the I/O output speed

00: Low speed

01: Medium speed

10: Fast speed

11: High speed

You can download project.
Other tutorials with STM32F7:
Tutorial: STM32F746 (STM32F7 Discovery) – how to turn on/off LED by button
Tutorial: STM32F746 (STM32F7 Discovery) – how to turn on LED (controlling GPIO)
STM32F746 discovery and AC6 (System Workbench for STM32)
How to begin with STM32 and why – tutorial

Share the article:
Show your
Maker soul!
Buy a T-Shirt
Coffee for Chiptron
Give a boost to the next article

Related Articles

This is another continue of STM32 tutorial (STM32F746 tutorial). I would like to show example code for turn on/off LED with button. This example code is able to use for another microcontrollers by ST as STM32L100, L152, STM32F103, F407 and…

We wrote a news about STM32F746 discovery and IDE by openstm32.org on the google+. https://time4ee.com/ got development board STM32F7 discovery by ST. We want to show MULTIPLATFORM (Linux – Ubuntu, Windows) development tools by http://openstm32.org Other tutorials with STM32F7: Tutorial:…

Digital Discovery is a crucial add-on if you have been using Analog Discovery 2, but its sampling rate was insufficient, there were not enough digital channels available, or there was too much noise to read data sent at higher speeds.…

If you program microcontrollers by STM (STM32F4, STM32F0, STM32L1) with Standard Peripheral Library your code is bigger than without Standard Peripheral Library. It is motivation why we can program of microcontrollers without Standard Peripheral Library. Nevertheless, if you program without…

A new member to STM32F7 family (e.g. also STM32F746 and STM32F769). STM32F723. STM32F723 is based on ARM? Cortex?-M7 32-bit RISC core with up to 216 MHz frequency. The microcontroller includes 512 kB FLASH and 256 kB SRAM. Clock, reset and…