Mi Microcontr troller r Archi hitectur tures and nd Ge - - PowerPoint PPT Presentation

mi microcontr troller r archi hitectur tures and nd ge
SMART_READER_LITE
LIVE PREVIEW

Mi Microcontr troller r Archi hitectur tures and nd Ge - - PowerPoint PPT Presentation

Mi Microcontr troller r Archi hitectur tures and nd Ge General al-Pu Purpose I/O 01204322 Embedded System Chaipo Chaiporn J n Jaik aikae aeo De Department of f Computer Engineering Kasetsart Unive versity Revised 2019-12-26 Ou


slide-1
SLIDE 1

Mi Microcontr troller r Archi hitectur tures and nd Ge General al-Pu Purpose I/O

Chaipo Chaiporn J n Jaik aikae aeo De Department of f Computer Engineering Kasetsart Unive versity

01204322 Embedded System

Revised 2019-12-26

slide-2
SLIDE 2

2

Ou Outline

  • Microprocessors, microcontrollers, and system on chip
  • STM32 microcontrollers
  • General-purpose I/O
slide-3
SLIDE 3

3

CP CPU/MP MPU vs.

  • s. MCU

MCU vs.

  • s. SoC
  • CPU/MPU
  • Central Processing Unit / Micro Processing Unit
  • MCU
  • Microcontroller Unit
  • SoC
  • System on Chip

SoC MCU CPU

slide-4
SLIDE 4

4

Ce Central Processi ssing Unit (CP CPU)

  • Typically contains
  • CU (Control Unit)
  • ALU (Arithmetic & Logic Unit)
  • Registers & caches
  • MMU (Memory Management Unit)

and FPU (Floating-Point Unit)

  • Large pin count (>100s) to connect to external address

and data buses

  • Requires external components to operate
  • Oscillator
  • ROM/RAM/flash
  • I/O controllers and devices: HDD, real-time clock, etc.

intel.com

slide-5
SLIDE 5

5

Mi Microcontroller r (MCU MCU)

  • Has common computing components built in:
  • CPU
  • ROM/RAM/flash
  • Basic peripherals: timers, analog-to-digital converter (ADC)
  • Basic I/O: general-purpose I/O (GPIO), UART, I2C, SPI
  • Possible with low pin count – only a few pins for I/O
  • Huge varieties available

microchip.com ti.com

slide-6
SLIDE 6

6

Sy System on Chip/Module (SoC/SoM SoM)

  • Combines MCU with application-

specific components on a single chip

  • r a single module
  • For examples:
  • Hardware multimedia encoder/decoder
  • Graphic controller: LCD display, HDMI
  • Network controller: Ethernet, Wi-Fi,

Bluetooth

  • USB controller
  • Digital-to-analog converter (DAC)

espressif.com st.com

slide-7
SLIDE 7

ST STM32 Mi Microcontrollers

slide-8
SLIDE 8

8

ST STM32 Microcontroller Families

https://www.st.com/en/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus.html ARM Cortex-M0/M0+ ARM Cortex-M3 ARM Cortex-M33 ARM Cortex-M4 ARM Cortex-M7

slide-9
SLIDE 9

9

ARM ARM Cortex-M M Instru ruction Sets

https://community.arm.com/cfs-file/__key/communityserver-blogs-components-weblogfiles/00-00-00-21-42/2021.ISA.png

slide-10
SLIDE 10

10

https://www.slideshare.net/element14/study-on-32bit-cortex-m3-powered-mcu-stm32f101

Ex Examp mple: STM TM32F1 F10x Block ck Diagr gram

slide-11
SLIDE 11

11

Cl Clock k Sources

  • Internal RC oscillator
  • 1% - 3% error, depending on temperature
  • External crystal oscillator
  • Typical accuracy around 20 ppm (0.002%)
  • Phase-Locked Loop (PLL) is used for frequency multiplier

PLL Demo

https://th.rs-online.com/web/p/crystal- units/8149507/

slide-12
SLIDE 12

12

Me Memory

  • ROM (Read-Only Memory)
  • Stores bootloader code developed by ST
  • Flash
  • Stores application code
  • SRAM (Static Random Access Memory)
  • Stores run-time application’s data
  • Does not retain value during power loss
  • EEPROM (Electrically Erasable Read-Only Memory)
  • Stores application’s configurations
  • Only available in some models; others may use EEPROM emulation

Image by PublicDomainPictures from Pixabay

slide-13
SLIDE 13

13

Gener General al-Pu Purpose I/O (GPIO)

  • Can be configured as either input or output
  • Output
  • States: push-pull, or open drain + pull-up / pull-down
  • Data can be obtained from data register
  • r from another peripheral
  • Input
  • States: floating, pull-up / pull-down, analog
  • Data can be directed to input data register
  • r to another peripheral

GPIO Pin

AN4899: STM32 GPIO configuration for hardware settings and low-power consumption

slide-14
SLIDE 14

14

In Inter errup upt C Controller er

  • Hardware informs CPU about a

service request

  • Program execution is stopped and

ISR (Interrupt Service Routine) is executed

  • MCU can process other tasks or

sleep to save energy

  • Nested vectored interrupt controller

(NVIC) allows prioritization of interrupts

https://lastminuteengineers.com/handling

  • esp32-gpio-interrupts-tutorial/

Priority: IRQ2 > IRQ1

ST’s training slides on Moving from 8 to 32 bits hands-on workshop

slide-15
SLIDE 15

15

Ti Timers s and Watchdogs

  • Timers are hardware components that independently count clock

ticks provided as input

  • Timers may reset themselves when
  • Triggered by application code
  • Counters overflow or reach predefined values (timeout)
  • A watchdog utilizes timeout signals to put

the system in a safe state (e.g., reset)

This Photo by Unknown Author is licensed under CC BY-SA-NC

https://visualgdb.com/tutorials/arm/stm32/timers/

slide-16
SLIDE 16

16

An Analog-to to-Di Digi gital Con

  • nverter (ADC

DC)

  • 12-bit or 16-bit resolution (depending on the model)
  • Based on SAR (successive approximation register) principle
  • Conversion is performed in several steps
  • Each step produces one bit from result to output
  • Similar to binary search

AN2834: How to get the best ADC accuracy in STM32 microcontrollers

slide-17
SLIDE 17

17

Po Power Management

  • Supports various low-power modes
  • E.g., for STM32L4 series

http://www.anglia-live.com/angliaCust/ldp/ang_ldpSt14.aspx

slide-18
SLIDE 18

18

Co Communications

  • USART – Universal Synchronous/Asynchronous Receiver/Transmitter
  • I2C – Inter-Integrated Circuit
  • SPI – Serial Peripheral Interface
  • CAN – Controller Area Network
  • USB – Universal Serial Bus

Image by tomekwalecki from Pixabay

slide-19
SLIDE 19

19

De Develop

  • pment Su

Suppor

  • rt
  • On-chip debugging/testing circuit
  • JTAG (Joint Test Action Group)
  • Also known as boundary-scan
  • Daisy-chain configuration
  • Serial Wire Debug (SWD)
  • Subset of JTAG
  • Less pins are required
  • Star configuration

TDI TDO

slide-20
SLIDE 20

ST STM32’s GPIO

Materials from AN4899 Application Note: STM32 GPIO configuration for hardware settings and low-power consumption

slide-21
SLIDE 21

21

GP GPIO IO E Equiv quivalen alent S Schema hematic ic

slide-22
SLIDE 22

22

Ou Output Mod

  • des
  • Push-pull output
  • Open-drain output
  • Can only sink current
  • External pull-up is often used

Output logic: HIGH

  • “pushed” to VDD
  • can source current

Output logic: LOW

  • “pulled” to VSS
  • can sink current
  • n
  • ff
  • n
  • ff
  • n
  • ff
  • ff
  • ff

Output logic: HIGH Output logic: LOW

slide-23
SLIDE 23

23

Ex Example: ample: LED LED O Out utput put

Schematic Wiring

slide-24
SLIDE 24

24

Co Configuri ring Output Pin

  • Make PA5 a push-pull output, labeled LED
slide-25
SLIDE 25

25

Wr Writing Output Logic

  • Using STM32 HAL (Hardware Abstraction Layer)
  • Turn LED on
  • Turn LED off

HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, 1) HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, 0)

slide-26
SLIDE 26

26

Input Input M Modes des

  • Each input pin can be configured to operate as floating,

pulled up, or pulled down

  • A Schmitt trigger is built into a pin to improve noise

immunity

floating pulled-up pulled-down

  • ff
  • n
  • ff
  • ff
  • ff
  • n

Schmitt Trigger Demo

slide-27
SLIDE 27

27

Ex Example: ample: S Swit itch Input h Input

Schematic Wiring

slide-28
SLIDE 28

28

Sw Switch Debouncing

  • Software solution: short delay after state change detected
  • Simple; no added cost
  • Keeps microcontroller waiting; lots of things can happen
  • Hardware solution: external capacitor + internal pull-up
  • Suitable for interrupt-driven code

input pin internal pull-up Switch Debouncing Demo

slide-29
SLIDE 29

29

Co Configuri ring Input Pin

  • Make PA4 a pulled-up input, labeled SW
slide-30
SLIDE 30

30

Re Reading Input Logic

  • Using STM32 HAL (Hardware Abstraction Layer)
  • The following function returns the current logic level

(either 0 or 1) or SW pin

HAL_GPIO_ReadPin(SW_GPIO_Port, SW_Pin)

slide-31
SLIDE 31

31

Elec Electric ical Limit al Limitatio ions o ns on I/ n I/O P Pins ins

  • Voltage and current characteristics of each I/O pin
  • Voltage and current characteristics of the whole device
  • These characteristics can be found in the device’s

datasheet

  • E.g., Section 6 Electrical Characteristics of STM32’s MCU

datasheets

slide-32
SLIDE 32

32

Ov Overall Vol

  • ltage Characteristics

Taken from ST’s STM32F042x4 datasheet

slide-33
SLIDE 33

33

Input Input P Port C Cha haracter eristics

Taken from ST’s STM32F042x4 datasheet

slide-34
SLIDE 34

34

Ou Output Por

  • rt Characteristics

Taken from ST’s STM32F042x4 datasheet

slide-35
SLIDE 35

35

Co Conclusi sion

  • Microcontrollers combine essential computing

components into single chips

  • System on chip (SoC) or system on module (SoM) integrate

more specific components into chips/modules

  • STM32 microcontrollers contain several components

crucial for embedded applications

  • General-purpose I/O are the most basic microcontroller’s

components for measuring and producing digital logic