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

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

Using the Digital I/O interface of STMicroelectronics STM32 Microcontrollers

Handling Asynchronous Events in MCUs A Light Keyboard Driver

Digital Input and Output

The Analog to Digital Converter (ADC)

Additional Timer Functionalities. Capture, Compare, PWM

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

Introduction to L.A.P. 1

Lab #4: GPIOs in Assembly Language Week of 18 February 2019

Real Time & Embedded Systems. STM32 GPIO and Timers

STM32F100RB processor GPIO notes rev 2

The Serial Peripheral Interface

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

Using Timers of Microchip PIC18F Microcontrollers

The I2C BUS Interface

The Controller Area Network (CAN) Interface

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

Input/Output Programming

Embedded C. ECE Rick

General Purpose Input/Output (GPIO)

General Purpose I/O ARM University Program Copyright ARM Ltd

ECE 362 Lab Verification / Evaluation Form Experiment 3

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

Goals. Grading Rubrics (Total = 20 points) Pre-lab assignment

ARM Microcontroller Course

ECE 362 Experiment 3: General Purpose I/O

AN2606 Application note

PAC52XX GPIO Peripheral Firmware Design

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

ELEC 3040/3050 Lab 5. Matrix Keypad Interface Using Parallel I/O

AN3268 Application note

Logic Programming with PROFETA

ELEC 3040/3050 Lab 5. Matrix Keypad Interface Using Parallel I/O

Embedded assembly is more useful. Embedded assembly places an assembly function inside a C program and can be used with the ARM Cortex M0 processor.

Modern C++ for Embedded Systems

Realtek Ameba-1 Power Modes

EZ GUI Expansion Board Design Guide

Interrupts and Exceptions

MICROCONTROLLER AND PLC LAB-436 SEMESTER-5

Education of Embedded Systems Programming in C and Assembly Based on ARM s Cortex-M Microprocessors

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

ARM Cortex M3 & General Purpose Input/Output (GPIO)

EasyPIC5 Development System

Prelab for Lab #2: Liquid Crystal Display (LCD) in C Week of 4 February 2019

Product Update. Errata to Z8 Encore! 8K Series Silicon. Z8 Encore! 8K Series Silicon with Date Codes 0402 and Later

8051 Microcontroller

96Boards UART Adapter User Guide

C8051F530A-DK C8051F530A DEVELOPMENT KIT USER S GUIDE. 1. Relevant Devices. 2. Kit Contents

Interconnects, Memory, GPIO

6. General purpose Input/Output

CubeComputer V4.1. General purpose on-board computer. Option Sheet

8255 Programmable Peripheral Interface Architecture MCT/UNIT III/NARASIMHARAJ/LECTURE NOTES /IV MECH A

< W3150A+ / W5100 Application Note for SPI >

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

Nu_EVB_001 Board Rev 2.0 User s Manual

Announcements Homework #3 due today. Ports. Outline for Today C8051 SFRs & Port I/O Worksheet #4 - simple I/O code. Using Ports

8:1 Serial Port Expander

Cookie User Manual. For NuMicro Edition 1.0. Rev. 1.0 Release: forum.coocox.org.

Infineon C167CR microcontroller, 256 kb external. RAM and 256 kb external (Flash) EEPROM. - Small single-board computer (SBC) with an

Chapter 09. Programming in Assembly

Concepts of Serial Communication

Microcontrollers in Micro-Increments

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

ELET114A Bluetooth Module DATASHEET. Website: / 7

Approved by: Date CET Initials Name Justification :20:12 NTJ Niels Thybo Johansen

Quick Start Guide TRK-KEA. Kinetis EA Series MCUs for Automotive Electronics Applications. StarterTRAK

EIE/ENE 334 Microprocessors

Embedded Programming with ARM Cortex-M3 Basic Experiments 1

Figure 1. Proper Method of Holding the ToolStick. Figure 2. Improper Method of Holding the ToolStick

CN310 Microprocessor Systems Design

Prototyping Module Datasheet

Network Embedded Systems Sensor Networks Fall Hardware. Marcus Chang,

CONTENTS BIGAVR2 KEY FEATURES 4 CONNECTING THE SYSTEM 5 INTRODUCTION 6

EE 354 November 13, 2017 ARM UART Notes

Introduction to ARM LPC2148 Microcontroller

A Resource Model For Adaptable Applications

Prefetch Cache Module

Learn how to communicate

USB Debug Adapter. Power USB DEBUG ADAPTER. Silicon Laboratories. Stop. Run. Figure 1. Hardware Setup using a USB Debug Adapter

User Manual Rev. 0. Freescale Semiconductor Inc. FRDMKL02ZUM

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

Please refer to "4. Evaluation Board" on page 2 for more information about these steps. Figure 1. System Connections

Downloaded from Elcodis.com electronic components distributor

MANUAL AND TUTORIAL EXERCISES

AN2606 Application note

Lecture 1. Course Overview and The 8051 Architecture

STM32 MICROCONTROLLER

VLSI Design Lab., Konkuk Univ. Yong Beom Cho LSI Design Lab

May 15, 2015 EE 354 Fall 2015 Lecture 6 Timers and timer interrupts

Symphony SoundBite Reference Manual

AN4311 Application note

C8051F700 Serial Peripheral Interface (SPI) Overview

_ V1.2. Motorola 68HC08 JL POD rev. D1. POD Hardware Reference

SYLLABUS UNIT - I 8086/8088 ARCHITECTURE AND INSTRUCTION SET

Also available for purchase separately are socket daughter boards for the QFN-11 and QFN-10 packages.

void GPIO_setup(){ GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA RCC_APB2Periph_GPIOC RCC_APB2Periph_AFIO,ENABLE);

User Manual For CP-JR ARM7 USB-LPC2148 / EXP

Am186ER/Am188ER AMD continues 16-bit innovation

Table 1: Cross Reference of Applicable Products. INTERNAL PIC NUMBER Arm Cortex M0+ UT32M0R GPIO Module QS30

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

Transcription:

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

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.

Digital I/O and SFR Each port x has 11 SFRs: MODER: configures each bit as input or output or other OSPEEDR: configures the maximum frequency of an output pin PUPDR: configures the internal pull-up or pull-down register IDR: the input data register ODR: the output data register BSRR: the bit set/reset register AFRL, AFRH: alternate function configuration registers LCKR: the bit lock register OTYPER: output type configuration (push-pull or open-drain) Accessing is made: By using the predefined structure pointers:gpioa, GPIOB, GPIOC By accessing the SFR as the structure pointer field: GPIOA->ODR

MODE Register MODER allows a programmer to define the functionality of a GPIO pin Each pin has 2 bits that permits the following configurations: 00: Input 01: Output 10: Alternate Function 11: Analog

Output Type Register OTYPER allows a programmer to configure the output stage of an output GPIO pin Each pin has 1 bits that permits the following configurations: 0: Push-pull 1: Open Drain

Output Speed Register OSPEEDR allows a programmer to define the speed of an output GPIO pin Each pin has 2 bits that permits the following configurations: x0: Low Speed 01: Medium Speed 11: High Speed

Pull-up/Pull-Down Register PUPDR defines the presence of a pull-up or pull-down restistor (or none) at the GPIO pin Each pin has 2 bits that permits the following configurations: 00: No pull-up/pull-down 01: Pull-up 10: Pull-down

Data Input/Output Registers Data Input/Ouput is performed through the IDR and ODR registers Each pin is mapped to the specific bit, so only 16 bits are used in the registers Bit set/reset and check operations are performed through logical mask operations

Single-bit Data Output Registers Single-bit data output (set or reset) can be performed through the BSRR register The register has two parts: set part and reset part To set a pin, a 1 must be written in the correspondent set part To reset a pin, a 1 must be written in the correspondent reset part

Single-bit Data Reset Registers Single-bit data reset can be also performed through the BRR register To reset a pin, a 1 must be written in the correspondent bit

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); }

First Example: Read a Pushbutton and lit the LED Let s replace input reading function with SFR #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 = (GPIOA->IDR & (1 << 10))!= 0; GPIO_write(GPIOB, 8,!pinval); }

First Example: Read a Pushbutton and lit the LED Let s replace output writing function with SFR #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 = (GPIOA->IDR & (1 << 10))!= 0; GPIOB->ODR = (GPIOB->ODR & (int32 t)0x100) (!pinval << 8); }

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