MCU Interfaces Introduction

Introduction to MCU interfaces including GPIO, ADC, PWM, I2C, SPI, I2S, UART.


MCU - Micro Control Unit (Microcontroller)

A MCU consist of a processor core, memory and I/O interfaces


8051 Microcontroller Architecture


Cortex-M0 MCU

NUC140 Functional Block Diagram


ESP32


RPi4


GPIO (General Purpose I/O)

Each IO pad drive/sink ~25mA, Entire Chip drive/sink ~200mA


ADC (Analog Digital Converter)

Vin is input voltage for ADC to sample

Vref is reference voltage for ADC to compare with Vin

2-bit ADC

12-bit ADC : output is a 12-bit binary code, so its value = 0 ~ 4095

Direct-Conversion ADC

Successive-Approximation ADC

Sigma-Delta ADC


DAC (Digital to Analog Converter)

Introduction to Digital-Analog Conversion

Binary-Weighted Resistor DAC

Sigma-Delta Digital Audio Converters (DAC)

Ref. 淺談 Delta-Sigma 之工作原理


PWM (Pulse Width Modulation)

CMRx+1 >= CNR: PWM output high
CMRx+1 < CNR: PWM output low

PWM Frequency = PWM_Clock/(prescale+1)*(clock divider)/(CNR+1)

Duty ratio = (CMR+1)/(CNR+1)


I2C (Inter-Integrated Circuit bus)

I2C bus 簡介


SPI (Serial peripheral interface)

Introduction to SPI Interface
4-wire SPI devices have four signals:

  • CS : Chip select
  • SCLK: SPI Clock
  • MOSI: Master out, slave in
  • MISO: Master in, slave out

SPI Mode 0, CPOL = 0, CPHA = 0: CLK idle state = low, data sampled on rising edge and shifted on falling edge.

SPI Mode 1, CPOL = 0, CPHA = 1: CLK idle state = low, data sampled on the falling edge and shifted on the rising edge.

SPI Mode 2, CPOL = 1, CPHA = 1: CLK idle state = high, data sampled on the falling edge and shifted on the rising edge.

SPI Mode 3, CPOL = 1, CPHA = 0: CLK idle state = high, data sampled on the rising edge and shifted on the falling edge.

Multislave Configuration

Daisy-Chain Configuration


I2S (Inter-IC Sound bus)

Introduction to the I2S Interface


UART(Universal Asynchronous Receiver/Transmitter)序列埠

BASICS OF UART COMMUNICATION

DB9 Connector

Protocol 通訊協定

  • Standard Packet : 8 data bits, even parity, 1 stop bit
    • If the parity bit is a 0 (even parity), the 1 bits in the data frame should total to an even number.
    • If the parity bit is a 1 (odd parity), the 1 bits in the data frame should total to an odd number. RS232 的Vpp電壓較高,有 6V~30V;UART 則是較低的 3.3V 或 5V
      RS232 為負邏輯, UART 為正邏輯,因此兩者波形是反相的
      Baud Rate

The main differences between RS-232, RS-422 and RS-485


Sensors

Photoresistor

Photoresistors, also known as light dependent resistors (LDR), are light sensitive devices most often used to indicate the presence or absence of light, or to measure the light intensity. In the dark, their resistance is very high, sometimes up to 1 MΩ, but when the LDR sensor is exposed to light, the resistance drops dramatically, even down to a few ohms, depending on the light intensity.


Thermistor

What is a Thermistor? Types of Thermistors and Applications Two types of Thermistor:

  • PTC (Positive Temperature Coefficient) Thermistor
  • NTC (Negative Temperature Coefficient) Thermistor

MQ series gas sensors

  • MQ-2 - Methane, Butane, LPG, smoke
  • MQ-3 - Alcohol, Ethanol, smoke
  • MQ-4 - Methane, CNG Gas
  • MQ-5 - Natural gas, LPG
  • MQ-6 - LPG, butane gas
  • MQ-7 - Carbon Monoxide
  • MQ-8 - Hydrogen Gas
  • MQ-9 - Carbon Monoxide, flammable gasses
  • MQ131 - Ozone
  • MQ135 - Air Quality (CO, Ammonia, Benzene, Alcohol, smoke)
  • MQ136 - Hydrogen Sulfide gas
  • MQ137 - Ammonia
  • MQ138 - Benzene, Toluene, Alcohol, Acetone, Propane, Formaldehyde gas, Hydrogen
  • MQ214 - Methane, Natural gas



This site was last updated June 05, 2023.