Using the Digital I/O interface of STMicroelectronics STM32 Microcontrollers

Similar documents
Using the Special Function Registers of the Digital I/O interface of STM32

Using the Special Function Registers of the Digital I/O interface of STM32

Handling Asynchronous Events in MCUs A Light Keyboard Driver

The Analog to Digital Converter (ADC)

Additional Timer Functionalities. Capture, Compare, PWM

Introduction to L.A.P. 1

The I2C BUS Interface

Using Timers of Microchip PIC18F Microcontrollers

The Serial Peripheral Interface

The Controller Area Network (CAN) Interface

General Purpose Input/Output (GPIO)

Digital Input and Output

Start a New Project with Keil MDK-ARM Version 5 and ST Micro Nucleo-F446RE

ELEC 3040/3050 Lab Manual Lab 2 Revised 8/20/14. LAB 2: Developing and Debugging C Programs in MDK-ARM for the STM32L100RC Microcontroller

ARM Microcontroller Course

Hands-On with STM32 MCU Francesco Conti

AN5181. Building a thermometer using the STM8 Nucleo-64 boards. Application note. Introduction

W7200 User s Guide. for STM32F10x Standard Library. - USART - GPIO - Timer. Version 1.0.0e

Hello, and welcome to this presentation of the STM32 general-purpose IO interface. It covers the general-purpose input and output interface and how

P-NUCLEO-IKA02A1. STM32 Nucleo pack: electrochemical toxic gas sensor expansion board with CO sensor. Description. Features

P-NUCLEO-6180X2. Proximity, gesture, ambient light sensor expansion board based on VL6180X for STM32L053R8. Description. Features

Interconnects, Memory, GPIO

STM32F1xx motor-control firmware for dspin. Quick guide

X-NUCLEO-IDW04A1. Wi-Fi expansion board based on SPWF04SA module for STM32 Nucleo. Features. Description

Zephyr OS Configuration via Device Tree

AN4515 Application note

Logic Programming with PROFETA

FiO Lite Datasheet FEATURES SAMPLE APPLICATIONS. FiO Lite

AN2606 Application note

Developing and Debugging C Programs in MDK-ARM for the STM32L100RC Microcontroller

By the end of Class. Outline. Homework 5. C8051F020 Block Diagram (pg 18) Pseudo-code for Lab 1-2 due as part of prelab

P-NUCLEO-53L1A1. VL53L1X nucleo pack with X-NUCLEO-53L1A1 expansion board and STM32F401RE nucleo board. Description. Features

Laboratory 1 Introduction to the Arduino boards

Using the GPIOs and interrupt controller to drive LEDs on STM8 Nucleo-64 boards

Getting started with the digital MEMS microphone expansion board based on MP34DT01-M for STM32 Nucleo

Developing Reusable Device Drivers for MCU's

XNUCLEO-F030R8, Improved STM32 NUCLEO Board

ECE 362 Lab Verification / Evaluation Form Experiment 3

P-NUCLEO-53L0A1. VL53L0X Nucleo pack with ranging, gesture detection sensor expansion board and STM32F401RE. Description. Features

UM2045 User manual. Getting started with the X-CUBE-NFC3 near field communication transceiver software expansion for STM32Cube.

CN310 Microprocessor Systems Design

Getting started with the software package for L6474 stepper motor driver X-CUBE-SPN1 expansion for STM32Cube

C8051F800-DK C8051F800 DEVELOPMENT KIT USER S GUIDE. 1. Relevant Devices. 2. Kit Contents. 3. Hardware Setup

LABORATORIO DI ARCHITETTURE E PROGRAMMAZIONE DEI SISTEMI ELETTRONICI INDUSTRIALI. Laboratory Lesson 2: - General Purpose I/O - SysTick

ECE 362 Lab Verification / Evaluation Form Experiment 5

AN2606 Application note

SQI FLASH click. PID: MIKROE-2828 Weight: 22 g

AN3268 Application note

STM32SnippetsL0. STM32L0xx Snippets firmware package. Features. Description

ECE 362 Experiment 3: General Purpose I/O

Mercury System SB310

PAC52XX GPIO Peripheral Firmware Design

AN3996 Application Note

User Manual Rev. 0. Freescale Semiconductor Inc. FRDMKL02ZUM

AN5123 Application note

STSW-BLUENRG1-DK. BlueNRG-1, BlueNRG-2 DK SW package

BMF055 Example Project Interrupts

AGH University of Science and Technology Cracow Department of Electronics

Introduction to ARM LPC2148 Microcontroller

Bluetooth Z8 Project Report

LABORATORIO DI ARCHITETTURE E PROGRAMMAZIONE DEI SISTEMI ELETTRONICI INDUSTRIALI

Realtek Ameba-1 Power Modes

Unlocking the Potential of Your Microcontroller

MANUAL AND TUTORIAL EXERCISES

AN4274 Application note

AN4311 Application note

Getting started with the X-CUBE-SPN3 high power stepper motor driver software expansion for STM32Cube

Getting started with X-CUBE-LED channel LED driver software expansion based on LED1642GW for STM32Cube

Ameba-Z DEV01 User Manual. This document defines pin out of Ameba-Z DEV01 demo board. Realtek

Getting started with X-NUCLEO-53L1A1 long distance ranging ToF sensor expansion board based on VL53L1X for STM32 Nucleo

Getting started with the FP-IND-PLCWIFI1 function pack for PLC management via Wi-Fi

Getting started with the X-CUBE-53L1A1 Time-of-Flight long distance ranging sensor software expansion for STM32Cube

Getting started with the X-CUBE-NFC5 high performance HF reader / NFC initiator IC software expansion for STM32Cube

AN3980 Application note

Getting started with the STM32 Nucleo pack for USB Type-C and Power Delivery with the Nucleo-F072RB board and the STUSB1602

User Manual Rev. 0. Freescale Semiconductor Inc. FRDMKL02ZUM

F²MC-8FX FAMILY 8-BIT MICROCONTROLLER MB95200H SERIES SPI SW REALIZATION USING GPIO APPLICATION NOTE

Reduce SW Development Time with DAVE 3. March, 2012

AN5179. RS232 communications with a terminal using the STM8 Nucleo-64 boards. Application note. Introduction

Embedded Systems. Read pages

Microcontroller Not just a case of you say tomarto and I say tomayto

Sub-1 GHz RF expansion board based on the SPSGRF-868 module for STM32 Nucleo. Description

X-NUCLEO-53L0A1 ranging and gesture detection sensor expansion board based on VL53L0X for STM32 Nucleo

CprE WiFi Bridge

STM32F100RB processor GPIO notes rev 2

UM2255 User manual. SPC58NG-DISP user manual. Introduction

UM2092 User manual. Basic metrology firmware for the STM32F103RD and the STPM32 devices. Introduction

STM32 Ecosystem workshop. T.O.M.A.S Team

EE 354 Fall 2015 Lecture 1 Architecture and Introduction

8051 Microcontroller

NUCLEO-L433RC-P NUCLEO-L452RE-P

Experiment 3. Interrupts. Hazem Selmi, Ahmad Khayyat

STM8L and STM32 L1 series. Ultra-low-power platform

Advanced Embedded Systems

EVALKITSTKNX. Miniature transceiver STKNX evaluation and development kit. Features

Nu_EVB_001 Board Rev 2.0 User s Manual

Getting the O in I/O to work on a typical microcontroller

Hardware abstraction layer for microcontrollers

Embedded Technosolutions

GPIO Library. Features. Operating modes. Software version and dependencies. Related application notes GPIO (1.1.0)

Transcription:

Using the Digital I/O interface of STMicroelectronics STM32 Microcontrollers ARSLAB - Autonomous and Robotic Systems Laboratory Dipartimento di Matematica e Informatica - Università di Catania, Italy santoro@dmi.unict.it L.A.P. 1 Course

What is a digital I/O interface? It is an interface in which each electrical pin may have two states: Logical 0 (it means 0V); Logical 1 (it means 5V or 3.3V on the basis of the VDD); Each line can be programmer as: an output (it generates current and can be used, for example, to lit a LED) an input (it receives current and can be used, for example, to read a pushbutton)

The General Purpose I/O (GPIO) Interface of STM32 MCUs of the STM32 family have several digital ports, called GPIOA, GPIOB, GPIOC,..., Each port has 16 bits and thus 16 electrical pins Pins are referred as Pxy, where x is the port name (A, B,..., E) and y is the bit (0, 1,..., 15). As an example, the pin PC3 is the bit 3 of the port C. Each PIN has also an alternate function, related to a peripheral e.g. Timer, UART, SPI, etc. According to the MCU package, not all bits are mapped to electrical pins. This is a choice by-design.

The General Purpose I/O (GPIO) Interface of STM32

Using the GPIO Interface To use a specific GPIO line (pin), the following operations are needed: Set-up 1 Initialize the whole GPIO port (this operation basically enables the clock line to the GPIO port) 2 Set the direction (input or output) of the pin you intend to use Operate Read the GPIO pin, if it is programmed as input, or Write the GPIO pin, if it is programmed as output These operations are made really simple using the stm32 unict lib

Using the GPIO Interface with stm32 unict lib Example: setting PA5 as output and using it Set-up 1 Initialize the whole GPIO port (this operation basically enables the clock line to the GPIO port) GPIO init(gpioa); 2 Set the direction of the pin you intend to use GPIO config output(gpioa, 5); Operate Write 0 to PA5: GPIO write(gpioa, 5, 0); Write 1 to PA5: GPIO write(gpioa, 5, 1);

The Nucleo64 Addon Board

First Example: Flashing a LED #include "stm32_unict_lib.h" int main() { // initialize port B GPIO_init(GPIOB); // configure pin PA5 as output GPIO_config_output(GPIOB, 8); } // infinite loop for (;;) { GPIO_write(GPIOB, 8, 1); // set PB8 to 1 delay_ms(500); // wait 0.5 secs GPIO_write(GPIOB, 8, 0); // set PB8 to 0 delay_ms(500); // wait 0.5 secs }

Using the GPIO Interface with stm32 unict lib Example: setting PC3 as input and using it Set-up 1 Initialize the whole GPIO port (this operation basically enables the clock line to the GPIO port) GPIO init(gpioc); 2 Set the direction of the pin you intend to use GPIO config input(gpioc, 3); Operate Read PC3 pin: int pinval = GPIO read(gpioc, 3); pinval can be 0 or 1

First Example: Read a Pushbutton and lit the LED #include "stm32_unict_lib.h" int main() { // pushbutton on PA10; LED on PB8 // initialize ports GPIO_init(GPIOA); GPIO_init(GPIOB); // configure pin PA10 as input GPIO_config_input(GPIOA, 10); // configure pin PB8 as output GPIO_config_output(GPIOB, 8); } // infinite loop for (;;) { int pinval = GPIO_read(GPIOA, 10); GPIO_write(GPIOB, 8,!pinval); }

Inside the code... What are the GPIOA, GPIOB,... variables? What are the prototypes of the GPIO functions? GPIOA, GPIOB,... are global variables defined in CMSIS libraries as: GPIO TypeDef * GPIOA; GPIO TypeDef * GPIOB;...; GPIO TypeDef is a structure whose fields are the special-function-registers (SFRs) of a GPIO port Each GPIOA, GPIOB,... variable is a pointer to a GPIO TypeDef and represents the address of the memory holding the SFRs of that port

The GPIO function prototypes Initialize a GPIO port: void GPIO init(gpio TypeDef * port); Configure a GPIO pin as input: void GPIO configure input(gpio TypeDef * port, int pin num); Configure a GPIO pin as output: void GPIO configure output(gpio TypeDef * port, int pin num); Write to an output pin: void GPIO write(gpio TypeDef * port, int pin num, int pin val); Read from an input pin: int GPIO read(gpio TypeDef * port, int pin num); Change the state of an output pin: void GPIO toggle(gpio TypeDef * port, int pin num);

Using the Digital I/O interface of STMicroelectronics STM32 Microcontrollers ARSLAB - Autonomous and Robotic Systems Laboratory Dipartimento di Matematica e Informatica - Università di Catania, Italy santoro@dmi.unict.it L.A.P. 1 Course