ARM Cortex-M
Programme a STM32F103C8T6 (the "Blue Pill" board) and you are working with a Cortex-M3 core running at 72 MHz with 20 kB SRAM and 64 kB Flash — all for under ₹80 at your local electronics shop. Almost every ECE project lab now uses Cortex-M devices, making this architecture the most practically relevant material in your embedded systems syllabus.
DMA
Sampling an analog signal at 44.1 kHz with the STM32 ADC and storing each conversion in a buffer without using DMA means the CPU is interrupted 44,100 times per second — every millisecond, nearly 44 interrupts steal cycles from everything else. With DMA1 Channel 1 configured for ADC1 in circular mode, the ADC result register is copied directly to a uint16_t array in RAM each time a conversion completes, and the CPU only wakes up when the half-transfer or full-transfer interrupt fires on a 256-sample block boundary.
Embedded C Programming
When an AVR ATmega328P GPIO pin needs to toggle at exactly 1 kHz to drive a buzzer, writing PORTB ^= (1<<PB5) inside a Timer1 compare-match ISR every 500 μs is the correct embedded C approach — not a delay loop, which burns CPU cycles and blocks interrupt handling. This single XOR register operation illustrates the key principle of embedded C: every line of code must be aware that you are talking directly to hardware registers, and missing the volatile keyword on a memory-mapped register variable can make the compiler cache the register value in a CPU register and never re-read it, causing bugs that are invisible in simulation but catastrophic on hardware.
GPIO Programming
On a STM32F103, writing a single 32-bit value to GPIOC_BSRR (bit set/reset register) — specifically 0x00002000 — sets PC13 high, turning off the onboard LED in one atomic, interrupt-safe operation. That register-level access, rather than HAL function calls, is what your embedded systems examiner expects you to explain.
I2C
Connecting an MPU-6050 IMU and a 24C02 EEPROM to the same two wires — SDA on PB7 and SCL on PB6 — is exactly what I2C was designed for. Both devices share the bus simultaneously, responding only when their 7-bit address appears after a START condition. The 24C02 listens at address 0x50, while the MPU-6050 sits at 0xD0 (write) or 0xD1 (read) depending on its AD0 pin. External 4.7 kΩ pull-up resistors to 3.3 V on both SDA and SCL lines are not optional — without them, the open-drain bus never returns high.
NVIC and Interrupts
On the STM32F103 running at 72 MHz, pressing a button triggers EXTI line 0, which fires through the NVIC before the CPU even finishes its current instruction. The Nested Vectored Interrupt Controller sits between peripherals and the Cortex-M3 core, deciding which interrupt gets serviced first. Without it, a UART receive interrupt and a systick timer interrupt would have no way to negotiate priority, and your serial data would drop bytes mid-transmission.
RTOS Basics
A medical pulse-oximeter firmware running on STM32 cannot afford to process sensor data and update the display in one giant while(1) loop — missed timing means a wrong reading. FreeRTOS solves this by giving each job its own task: a high-priority task at 1 ms period reads the MAX30100 sensor over I2C, while a lower-priority display task refreshes the SSD1306 OLED every 100 ms. The scheduler, triggered by SysTick every 1 ms, decides which task runs — the developer just assigns priorities and stack sizes.
SPI
Reading a temperature value from an LM74 or writing display data to an ILI9341 TFT controller both use SPI — a four-wire synchronous protocol where the STM32 acts as master, providing SCK on PA5, MOSI on PA7, and MISO on PA6, with chip-select NSS on PA4. SPI1 on the STM32F4 runs off APB2 and can clock at up to 42 MHz, making it the fastest peripheral bus option for high-throughput devices like ADCs and display controllers.
Timers and PWM
Controlling the brightness of an LED connected to PA8 on an STM32 board means writing to TIM1's capture-compare register — not toggling a GPIO in a loop. General-purpose timers like TIM2 and TIM3 on the STM32F4 can generate PWM on multiple channels simultaneously, and at 84 MHz with a prescaler of 84 and an ARR of 1000, each timer tick is exactly 1 µs. This makes frequency and duty cycle calculations clean and direct in exam problems.
UART
When an STM32 sends "Hello" over USART2 to a PC terminal at 9600 baud, each character leaves PA2 as a 10-bit frame — one start bit, eight data bits, and one stop bit — with no clock line involved. UART is asynchronous, meaning both ends must agree on baud rate beforehand; even a 2% mismatch accumulates over a frame and causes framing errors by the third or fourth byte. On the STM32, USART1 is the go-to debug port because it sits on APB2 and can run at up to 4.5 Mbps.
Notes
Embedded Systems — Short notes
10 topics · One-page revision notes for each concept.