Microcontroller Serial Interfaces

Microcontroller Serial Interfaces

Microcontroller Serial Interfaces Dr. Francesco Conti [email protected] Microcontroller System Architecture Each MCU (micro-controller unit) is characterized by: • Microprocessor • 8,16,32 bit architecture • Usually “simple” in-order microarchitecture, no FPU Example: STM32F101 MCU Microcontroller System Architecture Each MCU (micro-controller unit) is characterized by: • Microprocessor • 8,16,32 bit architecture • Usually “simple” in-order microarchitecture, no FPU • Memory • RAM (from 512B to 256kB) • FLASH (from 512B to 1MB) Example: STM32F101 MCU Microcontroller System Architecture Each MCU (micro-controller unit) is characterized by: • Microprocessor • 8,16,32 bit architecture • Usually “simple” in-order microarchitecture, no FPU • Memory • RAM (from 512B to 256kB) • FLASH (from 512B to 1MB) • Peripherals • DMA • Timer • Interfaces • Digital Interfaces • Analog Timer DMAs Example: STM32F101 MCU Microcontroller System Architecture Each MCU (micro-controller unit) is characterized by: • Microprocessor • 8,16,32 bit architecture • Usually “simple” in-order microarchitecture, no FPU • Memory • RAM (from 512B to 256kB) • FLASH (from 512B to 1MB) • Peripherals • DMA • Timer • Interfaces • Digital • Analog • Interconnect Example: STM32F101 MCU • AHB system bus (ARM-based MCUs) • APB peripheral bus (ARM-based MCUs) Microcontroller System Architecture Each MCU (micro-controller unit) is characterized by: • Microprocessor • 8,16,32 bit architecture • Usually “simple” in-order microarchitecture, no FPU • Memory • RAM (from 512B to 256kB) • FLASH (from 512B to 1MB) • Peripherals • DMA • Timer • Interfaces • Digital • Analog • Interconnect Example: STM32F101 MCU • AHB system bus (ARM-based MCUs) • APB peripheral bus (ARM-based MCUs) MCU Interfaces • Digital • Several protocols for inter-chip communication UART, I2C, SPI, USB,… • Serial communication protocols • Meant for short distances “inside the box” / on-board • Low complexity • Low cost • Low speed ( a few Mb/s at the fastest ) • Serial communication is employed where it is not practical, either in physical or cost terms, to move data in parallel between systems. MCU Interfaces • Digital • Several protocols for inter-chip communication UART, I2C, SPI, USB,… • Serial communication protocols • Meant for short distances “inside the box” / on-board • Low complexity • Low cost • Low speed ( a few Mb/s at the fastest ) • Serial communication is employed where it is not practical, either in physical or cost terms, to move data in parallel between systems. • Analog • ADC (Analog-to-Digital Converter) • DAC (Digital-to-Analog Converter) • Comparator Memory-Mapped Peripherals Peripherals such as external interfaces in a microcontroller system are accessible via memory-mapped registers: • for peripheral configuration • for I/O addresses Memory Map memory mapped Cortex-M3 load/store MCU core Memory-Mapped Peripherals Suppose our purpose is to blink a LED (i.e., a GPIO pin): GPIOC_LED0_ADDR Memory-Mapped Peripherals Suppose our purpose is to blink a LED (i.e., a GPIO pin): GPIOC_LED0_ADDR Memory-Mapped Peripherals Suppose our purpose is to blink a LED (i.e., a GPIO pin): STORE GPIOC_LED0_ADDR,0x1 GPIOC_LED0_ADDR Memory-Mapped Peripherals Suppose our purpose is to blink a LED (i.e., a GPIO pin): STORE GPIOC_LED0_ADDR,0x1 GPIOC_LED0_ADDR Memory-Mapped Peripherals Suppose our purpose is to blink a LED (i.e., a GPIO pin): STORE GPIOC_LED0_ADDR,0x1 GPIOC_LED0_ADDR Microcontroller External Pins Configuration MCUs are often pin-limited • Not enough I/O pins for all I/O peripherals and functions! Microcontroller External Pins Configuration MCUs are often pin-limited • Not enough I/O pins for all I/O peripherals and functions! • Pins have to be multiplexed (shared) between peripherals and functions Microcontroller External Pins Configuration MCUs are often pin-limited • Not enough I/O pins for all I/O peripherals and functions! • Pins have to be multiplexed (shared) between peripherals and functions Most pins can be configured for several functions: • As input or output pin • As an interrupt pin • Setup a pull-up / pull-down internal resistor (NO floating pins!) Microcontroller External Pins Configuration MCUs are often pin-limited • Not enough I/O pins for all I/O peripherals and functions! • Pins have to be multiplexed (shared) between peripherals and functions Most pins can be configured for several functions: • As input or output pin • As an interrupt pin • Setup a pull-up / pull-down internal resistor (NO floating pins!) • Assigned as general-purpose I/O (GPIO) or to a specific peripheral • Digital peripherals such as UARTs, SPIs, I2Cs • Analog peripherals such as ADCs or DACs Microcontroller External Pins Configuration Example to understand how this functionality works in a MCU • the specific circuit and register may change wildly between MCUs Memory-Mapped registers Function Select Register PxSEL Interrupt Edge Select Register PxIES Interrupt Enable Register PxIE Interrupt Flag Register PxIFG PAD 1 Direction Register PxDIR Output Register PxOUT Input Register PxIN 7 6 5 4 3 2 1 0 Serial Interface Standards https://xkcd.com/927/ I2C: Inter-Integrated Circuit Bus - 1 • Usually pronounced “I-Squared-C” • Introduced by Philips (now NXP Semiconductors) in 1982 I2C: Inter-Integrated Circuit Bus - 1 • Usually pronounced “I-Squared-C” • Introduced by Philips (now NXP Semiconductors) in 1982 • Used for communication with external peripherals, for example: • EEPROMs • thermal sensors • real-time clocks I2C: Inter-Integrated Circuit Bus - 1 • Usually pronounced “I-Squared-C” • Introduced by Philips (now NXP Semiconductors) in 1982 • Used for communication with external peripherals, for example: • EEPROMs • thermal sensors • real-time clocks • Also used as a control interface for signal processing devices with separate data interfaces, for example: • radio frequency tuners • video decoders and encoders • audio processors I2C: Inter-Integrated Circuit Bus - 2 • Three supported speed modes: • slow (under 100 Kbps) • fast (400 Kbps) • high-speed (3.4 Mbps) – in I2C v.2.0 • Maximum inter-IC distance of about 3 meters • (for moderate speeds, less for high-speed) I2C: Inter-Integrated Circuit Bus - 2 • Three supported speed modes: • slow (under 100 Kbps) • fast (400 Kbps) • high-speed (3.4 Mbps) – in I2C v.2.0 • Maximum inter-IC distance of about 3 meters • (for moderate speeds, less for high-speed) • Can support multi-master mode • For complex applications • Communication is always started by a master, both in single-master and multi-master mode I2C: Inter-Integrated Circuit Bus - 2 • Three supported speed modes: • slow (under 100 Kbps) • fast (400 Kbps) • high-speed (3.4 Mbps) – in I2C v.2.0 • Maximum inter-IC distance of about 3 meters • (for moderate speeds, less for high-speed) • Can support multi-master mode • For complex applications • Communication is always started by a master, both in single-master and multi-master mode • Half-duplex synchronous communication scheme • the master of the communication generates the clock (SCL) on which data (SDA) is synchronized I2C: Inter-Integrated Circuit Bus - 3 • Based on two lines: • SCL (serial clock) • SDA (serial data) • Pull-Up resistors, Pull-Down by open-drain drivers • Wired-AND: if any driver pulls down, the line is low (avoids short circuits) • Any module on the bus can act as master, slave or both • typical case: MCU is the master, peripherals/sensors are slaves I2C: Interface Protocol address (7 or 10 bits) ack bit ack bit SCL SDA start bit direction bit data payload stop bit • In idle, both SCL and SDA are pulled-up to 1 I2C: Interface Protocol address (7 or 10 bits) ack bit ack bit SCL SDA start bit direction bit data payload stop bit 1. To start the communication, the master: • asserts the start bit (SDA 1→0 transition while SCL is still 1) • then, it starts generating the SCL clock • except for the start and stop bits, SDA transitions only when SCL is 0 I2C: Interface Protocol address (7 or 10 bits) ack bit ack bit SCL SDA start bit direction bit data payload stop bit 2. The master transmits the slave address: • broadcasted to all devices on the I2C bus • used to select the target slave • either 7 bits or 10 bits (newer devices – 7 bits address space is small!) • in the example, the address is 7’b1000001 I2C: Interface Protocol address (7 or 10 bits) ack bit ack bit SCL SDA start bit direction bit data payload stop bit 3. The master transmits a direction bit: • a 0 for master → slave (write) transfer • a 1 for slave → master (read) transfer • in the example, suppose a write transfer I2C: Interface Protocol address (7 or 10 bits) ack bit ack bit SCL SDA start bit direction bit data payload stop bit 4. The slave then acknowledges reception: • by driving SDA to 0 • if not acknowledged, the transaction must be repeated by the master I2C: Interface Protocol address (7 or 10 bits) ack bit ack bit SCL SDA start bit direction bit data payload stop bit 5. The master transmits its data payload: • each payload packet is 8 bits • there might be more than one packet, depending on application • in the example, data payload is 8’b00110100 I2C: Interface Protocol address (7 or 10 bits) ack bit ack bit SCL SDA start bit direction bit data payload stop bit 6. The slave acknowledges reception of the data packet: • 1 ack bit every 8 payload bits • slave must acknowledge each packet I2C: Interface Protocol address (7 or 10 bits) ack bit ack bit SCL SDA start bit direction bit data payload stop bit 7. At the end of the transfer, the master transmits a stop bit: •

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    136 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us