माइक्रोकंट्रोलर का परिचय
माइक्रोकंट्रोलर क्या है, कैसे चुनें — GPIO, SPI, I2C पेरिफेरल।
A microcontroller (MCU) is a self-contained computer on a single IC: processor core, flash memory, SRAM and programmable I/O peripherals. MCUs run a single program loop directly on hardware with microsecond response times — ideal for real-time control, embedded sensing and battery-powered IoT.
MCU vs Microprocessor vs SBC
A microprocessor (MPU) needs external RAM, Flash and peripherals. A microcontroller integrates all on one chip. An SBC (Raspberry Pi) has a powerful MPU running Linux. MCUs cost ¢25–$5, boot in microseconds and run on button batteries.
| Type | Example | OS | Boot Time | Best For |
|---|---|---|---|---|
| MCU | STM32F103 | None (bare-metal) | < 1 ms | Real-time control, IoT |
| MCU (RTOS) | ESP32-S3 | FreeRTOS | < 100 ms | IoT with Wi-Fi/BT |
| SBC | Raspberry Pi 5 | Linux | 10–20 s | Edge AI, Linux apps |
GPIO, Timers and Interrupts
GPIO pins can be configured as digital input, digital output or alternate-function (SPI, I2C, UART, PWM). Timers generate interrupts or PWM signals independently of the main loop. Interrupts immediately suspend the main program and run a handler function.
- ▸Never directly source/sink more than the pin rated current (typically 8–25 mA).
- ▸ADC pins sample analog voltages and convert them to a digital number.
Communication Protocols: UART, SPI, I2C
UART: 2 wires, asynchronous, point-to-point. SPI: 4 wires, synchronous, full-duplex, up to 50+ MHz. I2C: 2 wires, addressable — many devices share the same bus, each with a unique 7-bit address.