mi microcontr troller r archi hitectur tures and nd ge
play

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


  1. 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

  2. Ou Outline • Microprocessors, microcontrollers, and system on chip • STM32 microcontrollers • General-purpose I/O 2

  3. CP CPU/MP MPU vs. s. MCU MCU vs. s. SoC • CPU/MPU ◦ Central Processing Unit / Micro Processing Unit • MCU ◦ Microcontroller Unit • SoC CPU ◦ System on Chip MCU SoC 3

  4. Central Processi Ce ssing Unit (CP CPU) • Typically contains ◦ CU (Control Unit) ◦ ALU (Arithmetic & Logic Unit) ◦ Registers & caches ◦ MMU (Memory Management Unit) and FPU (Floating-Point Unit) intel.com • 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. 4

  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, I 2 C, SPI • Possible with low pin count – only a few pins for I/O • Huge varieties available microchip.com ti.com 5

  6. Sy System on Chip/Module (SoC/SoM SoM) • Combines MCU with application- specific components on a single chip or a single module • For examples: ◦ Hardware multimedia encoder/decoder ◦ Graphic controller: LCD display, HDMI espressif.com ◦ Network controller: Ethernet, Wi-Fi, Bluetooth ◦ USB controller ◦ Digital-to-analog converter (DAC) st.com 6

  7. ST STM32 Mi Microcontrollers

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

  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 9

  10. Ex Examp mple: STM TM32F1 F10x Block ck Diagr gram https://www.slideshare.net/element14/study-on-32bit-cortex-m3-powered-mcu-stm32f101 10

  11. Cl Clock k Sources • Internal RC oscillator ◦ 1% - 3% error, depending on temperature https://th.rs-online.com/web/p/crystal- units/8149507/ • External crystal oscillator ◦ Typical accuracy around 20 ppm (0.002%) • Phase-Locked Loop (PLL) is used for frequency multiplier PLL Demo 11

  12. Me Memory • ROM (Read-Only Memory) ◦ Stores bootloader code developed by ST • Flash ◦ Stores application code Image by PublicDomainPictures from Pixabay • 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 12

  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 or from another peripheral GPIO Pin • Input ◦ States: floating, pull-up / pull-down, analog ◦ Data can be directed to input data register or to another peripheral AN4899: STM32 GPIO configuration for hardware settings and low-power consumption 13

  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 https://lastminuteengineers.com/handling sleep to save energy -esp32-gpio-interrupts-tutorial/ • Nested vectored interrupt controller (NVIC) allows prioritization of interrupts ST’s training slides on Moving from Priority: IRQ2 > IRQ1 8 to 32 bits hands-on workshop 14

  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/ 15

  16. An Analog-to to-Di Digi gital Con onverter (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 16

  17. Po Power Management • Supports various low-power modes • E.g., for STM32L4 series http://www.anglia-live.com/angliaCust/ldp/ang_ldpSt14.aspx 17

  18. Co Communications • USART – Universal Synchronous/Asynchronous Receiver/Transmitter • I 2 C – Inter-Integrated Circuit • SPI – Serial Peripheral Interface • CAN – Controller Area Network • USB – Universal Serial Bus Image by tomekwalecki from Pixabay 18

  19. De Develop opment Su Suppor ort • On-chip debugging/testing circuit • JTAG (Joint Test Action Group) ◦ Also known as boundary-scan ◦ Daisy-chain configuration TDO TDI • Serial Wire Debug (SWD) ◦ Subset of JTAG ◦ Less pins are required ◦ Star configuration 19

  20. ST STM32’s GPIO Materials from AN4899 Application Note: STM32 GPIO configuration for hardware settings and low-power consumption

  21. GP GPIO IO E Equiv quivalen alent S Schema hematic ic 21

  22. Output Mod Ou odes Output logic: HIGH Output logic: LOW • Push-pull output - “pushed” to V DD - “pulled” to V SS - can source current - can sink current on off • Open-drain output on off ◦ Can only sink current ◦ External pull-up is often used off off on off Output logic: HIGH Output logic: LOW 22

  23. Ex Example: ample: LED LED O Out utput put Schematic Wiring 23

  24. Configuri Co ring Output Pin • Make PA5 a push-pull output , labeled LED 24

  25. Wr Writing Output Logic • Using STM32 HAL (Hardware Abstraction Layer) • Turn LED on HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, 1) • Turn LED off HAL_GPIO_WritePin(LED_GPIO_Port, LED_Pin, 0) 25

  26. Input Input M Modes des • Each input pin can be configured to operate as floating , pulled up , or pulled down on off off off off on floating pulled-up pulled-down • A Schmitt trigger is built into a pin to improve noise immunity Schmitt Trigger Demo 26

  27. Ex Example: ample: S Swit itch Input h Input Schematic Wiring 27

  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 internal pull-up input pin Switch Debouncing Demo 28

  29. Configuri Co ring Input Pin • Make PA4 a pulled-up input , labeled SW 29

  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) 30

  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 31

  32. Overall Vol Ov oltage Characteristics Taken from ST’s STM32F042x4 datasheet 32

  33. Input Input P Port C Cha haracter eristics Taken from ST’s STM32F042x4 datasheet 33

  34. Output Por Ou ort Characteristics Taken from ST’s STM32F042x4 datasheet 34

  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 35

Recommend


More recommend