PBCST504Semester 5
Microcontrollers
Computer Science and Engineering
First exam: no past papers yet
This course has never been examined. Topics and papers come from the official syllabus, the model paper and the ktunotes notes, so there is no accuracy score.
CST307 was not used: only 4% of its questions fit this syllabus.
Set 1 and Set 2 cover 23 of 23 topic groups. Cover every module.
Topics, ranked
Study from the top.
By module
Order
- 1
USART/UART: Frame Format, Baud Rate, Parity, Flow Control
Short note
- USART is the Universal Synchronous/Asynchronous Receiver/Transmitter. It converts parallel data to serial on transmit and serial to parallel on receive, using TX and RX pins.
- Asynchronous frame: start bit (0), 5 to 9 data bits (usually 8, LSB first), optional parity bit, then 1 or 2 stop bits (1). The idle line is high.
- 8N1 means 8 data bits, no parity, 1 stop bit. That is 10 bits per byte. At 9600 baud one byte takes about 1.04 ms. At 115200 baud it takes about 87 microseconds.
- Parity (even or odd) gives simple single-bit error detection. Both devices must use the same baud rate, data bits, parity and stop bits.
- Hardware flow control uses RTS and CTS lines so a receiver can tell the sender to pause. Common baud rates: 9600, 19200, 38400, 57600, 115200.
For detail: Notes pages 3–4 (opens in a new tab), Notes pages 9–11 (opens in a new tab)
- 2
Operating Modes (Thread/Handler), Privilege Levels, MSP/PSP & the CONTROL Register
Short note
- Cortex-M has two modes. Thread mode runs normal application code. Handler mode runs exceptions and ISRs, and is always privileged.
- Privilege levels: privileged has full access; unprivileged is restricted from some registers and memory, set up by the MPU. Thread mode can be either.
- Two stack pointers: MSP (Main, default, used in Handler mode and at reset) and PSP (Process, usually for RTOS tasks). R13 shows whichever is active.
- CONTROL register: bit 0 nPRIV (0 = privileged, 1 = unprivileged), bit 1 SPSEL (0 = MSP, 1 = PSP). Only privileged code can write it.
- Handler mode always uses MSP and privileged access. Exception entry switches to Handler mode; exit returns to the interrupted mode, which is Thread mode unless exceptions were nested.
For detail: Notes pages 44–45 (opens in a new tab)
- 3
IoT Protocols: MQTT vs CoAP
Short note
- MQTT is a lightweight publish/subscribe protocol over TCP. Clients publish to topics (such as lab/room1/humidity); a central broker routes messages to subscribers.
- MQTT concepts: broker, topic, publish, subscribe, retained message and last-will message. QoS 0 is at most once, QoS 1 at least once, QoS 2 exactly once.
- CoAP is a REST-like request/response protocol, usually over UDP, for constrained devices. Methods: GET, POST, PUT, DELETE. Resources use URIs such as coap://host/temperature.
- CoAP messages can be confirmable or non-confirmable and return response codes. It maps easily to HTTP.
- MQTT vs CoAP: MQTT is pub/sub, TCP and broker-based, good for telemetry. CoAP is client/server, UDP and direct, good for querying or controlling a device resource.
For detail: Notes pages 2–3 (opens in a new tab), Notes pages 14–15 (opens in a new tab), Notes pages 20–22 (opens in a new tab)
- 4
Seven-Segment Display Interfacing
Short note
- A seven-segment display has seven LEDs (a to g) plus a decimal point (dp), arranged as an 8. Each segment can be switched on or off to show digits 0 to 9.
- Common cathode (CC): all cathodes to GND, a segment lights when its pin is HIGH. Common anode (CA): all anodes to VCC, a segment lights when LOW.
- Each segment needs a current-limiting resistor, typically 220 to 330 ohm. Segment pins a to g go to GPIO pins such as PA0 to PA6.
- CC digit codes (gfedcba): 0 = 0x3F, 1 = 0x06, 2 = 0x5B, 3 = 0x4F, 4 = 0x66, 5 = 0x6D, 6 = 0x7D, 7 = 0x07, 8 = 0x7F, 9 = 0x6F. For CA, invert the code.
- To show a digit, write each bit of its code to the segment pins with HAL_GPIO_WritePin, then HAL_Delay between digits.
For detail: Notes pages 43–44 (opens in a new tab), Notes page 47 (opens in a new tab)
- 5
Bus Architecture: AMBA, AHB, APB & the Bus Matrix
Short note
- AMBA (Advanced Microcontroller Bus Architecture) is ARM's standard on-chip bus specification for SoCs. It includes AHB, APB and AXI.
- AHB: high-speed, high-bandwidth bus for CPU, fast memory and DMA, with burst and pipelined transfers.
- APB: simple, low-power, low-speed bus for peripherals such as UART, timers and GPIO. An AHB-to-APB bridge connects the two.
- Peripherals use APB because they do not need AHB bandwidth, which saves power and design complexity.
- On STM32 the bus matrix lets several masters (CPU, DMA) reach different slaves (Flash, SRAM, peripherals) at once. AXI is the advanced high-speed bus used in larger cores.
For detail: Notes pages 56–57 (opens in a new tab)
- 6
First Program: LED Interfacing with HAL (GPIO)
Short note
- Toggle an LED with HAL: HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); HAL_Delay(500); inside while(1). HAL_Delay takes milliseconds.
- Other HAL calls: HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET) turns it on, GPIO_PIN_RESET turns it off. HAL_GPIO_ReadPin() reads an input.
- Register version: RCC->AHB2ENR1 |= RCC_AHB2ENR1_GPIOAEN; GPIOA->MODER &= ~(3<<10); GPIOA->MODER |= (1<<10); GPIOA->ODR ^= (1<<5). Same result, harder to read.
- Steps in CubeIDE: create project, set the pin as GPIO_Output, generate code, add the HAL code in the while(1) loop, build, flash and debug.
For detail: Notes pages 41–42 (opens in a new tab), Notes page 63 (opens in a new tab)
- 7
IoT Security Principles and Common Threats
Short note
- Security principles are the CIA triad: Confidentiality (only authorised users see data), Integrity (data is not altered) and Availability (service stays up). Also authentication.
- Common threats: weak or default passwords, unencrypted traffic (eavesdropping), poor authentication, firmware bugs, insecure updates, physical tampering, DoS and privacy leaks.
- Protection: strong unique credentials, encryption such as TLS or DTLS, authentication, signed secure firmware updates, secure boot, and minimal open interfaces.
- Hardware help: ARM TrustZone isolates keys and security code in the Secure state, away from the ordinary application.
- Keep keys out of normal firmware and protect telemetry and control commands, since attackers can inject commands as well as read data.
For detail: Notes page 3 (opens in a new tab), Notes page 30 (opens in a new tab), Notes page 46 (opens in a new tab)
- 8
Serial Communication Fundamentals & Serial Terminal Application
Short note
- Serial communication sends data one bit at a time over one line. Parallel sends many bits at once on many wires: faster over short distances but needs more pins and suffers skew.
- Asynchronous serial has no shared clock; both ends agree on baud rate and use start and stop bits. Synchronous serial sends a clock line (SPI, I2C, USART sync mode).
- A serial terminal (PuTTY, Tera Term, RealTerm) on the PC sends and shows text from the STM32 USART, used for debugging and monitoring sensor values.
- Terminal setup steps: pick the COM port, then set the same baud rate, data bits, parity, stop bits and flow control on both sides, for example 115200 8N1, no flow control.
- Simplex is one direction, half duplex is both directions but one at a time, full duplex is both at once. UART TX and RX lines give full duplex.
For detail: Notes pages 2–5 (opens in a new tab)
- 9
Comparison of USART, I2C, SPI and CAN
Short note
- USART: 2 wires (TX, RX), asynchronous or synchronous, point to point, full duplex, no addressing. Used for PC links and modules like GSM or Bluetooth.
- I2C: 2 wires (SDA, SCL), synchronous, multi-master multi-slave with 7-bit addresses, half duplex, 100 kHz to 1 MHz. Used for sensors, EEPROM and RTC.
- SPI: usually 4 wires (SCLK, MOSI, MISO, CS), synchronous, one master, full duplex, fastest of the four, CS per slave. Used for flash, SD cards and displays.
- CAN: 2 differential wires (CANH, CANL), asynchronous (no clock line), multi-master bus with ID-based priority, up to 1 Mbit/s classical, long distance and noise-robust.
- SPI vs I2C in one line: SPI is faster and full duplex but needs more wires and CS lines; I2C needs only 2 wires and uses addresses and ACK but is slower.
For detail: Notes page 7 (opens in a new tab), Notes page 20 (opens in a new tab), Notes page 26 (opens in a new tab)
- 10
ARM Registers: R0-R12, SP, LR, PC & the Program Status Register (xPSR)
Short note
- Cortex-M register set: R0 to R12 general purpose, R13 SP, R14 LR, R15 PC, and xPSR. R0 to R7 are low registers; R8 to R12 are high registers.
- SP is the stack pointer (LIFO, used for calls, locals and interrupt context). LR holds the return address for BL. PC holds the address of the next instruction.
- xPSR combines APSR, IPSR and EPSR. Condition flags in APSR: N negative, Z zero, C carry, V overflow.
- Correction: the notes show CPSR and banked registers per mode, which is ARM7/classic ARM. Cortex-M uses xPSR and two stack pointers, MSP and PSP, with no banked mode registers.
- A conditional branch such as BEQ tests the Z flag. CMP R0, R1 sets flags without storing a result.
For detail: Notes pages 44–47 (opens in a new tab)
- 11
Relay Interfacing
Short note
- A relay is an electromagnetic switch. A small coil current moves the armature to switch a separate high-power load, giving isolation between the MCU and the load.
- Parts: coil, armature, spring, contacts and iron core. Terminals: COM, NO (open when off), NC (closed to COM when off). Energising the coil joins COM to NO.
- A GPIO gives about 8 to 20 mA but the coil needs roughly 70 to 100 mA, so use an NPN transistor driver (BC547 or 2N2222) with a base resistor (about 1 kohm).
- Flyback diode (1N4007) across the coil absorbs the reverse voltage spike when the coil switches off and protects the transistor and MCU.
- HAL: HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_SET) turns the relay on, GPIO_PIN_RESET turns it off, with HAL_Delay(2000) between. Many relay modules include the driver and optocoupler.
For detail: Notes pages 58–61 (opens in a new tab)
- 12
IoT: Introduction, Characteristics & Architecture Layers
Short note
- IoT is a network of physical devices with sensors, software and connectivity that collect and exchange data over the Internet, often with little human input.
- Key characteristics: connectivity, sensing, small constrained devices, low power, large scale, remote monitoring and control, and data-driven action.
- Typical architecture layers: perception (sensors and actuators), network (Wi-Fi, BLE, LoRa, GSM), middleware or processing (gateway, cloud) and application (dashboards, apps).
- Data flow: sensor, STM32 node, wireless link, gateway, cloud, then application or user. Commands can flow back to actuators.
- IoT protocols must suit low bandwidth, low power, small packets and unreliable links. MQTT and CoAP are the main application layer choices.
For detail: Notes page 3 (opens in a new tab), Notes page 14 (opens in a new tab), Notes page 48 (opens in a new tab)
- 13
Sensor Interfacing with ADC: LM35, LDR, Microphone
Short note
- LM35 gives 10 mV per degree C (0 C = 0 V, 25 C = 250 mV), range -55 to +150 C. Pins: VCC, OUT (to ADC pin such as PA0), GND.
- LM35 temperature in C = (ADC value x Vref / 4095) / 0.01, which is ADC x 3.3 x 100 / 4095 on a 3.3 V reference.
- LDR works on photoconductivity: more light gives more free electrons, so resistance falls. Use it in a voltage divider with a fixed resistor to get a voltage for the ADC.
- Microphone converts sound to a small analog voltage. Electret module has VCC, GND, AO and DO; use the AO pin for ADC. Signal chain: sound, mic, analog voltage, ADC, digital data.
- All three sensors give analog outputs, so each connects to an ADC1 input channel such as PA0 and is read with HAL_ADC_GetValue().
For detail: Notes pages 71–77 (opens in a new tab)
- 14
RTOS Concepts and FreeRTOS on STM32: Task Creation and Scheduling
Short note
- An RTOS runs several tasks (threads) with a scheduler that gives deterministic, priority-based timing. FreeRTOS is the common choice on STM32.
- Create a task with xTaskCreate(function, name, stack depth in words, parameter, priority, &handle). It returns pdPASS on success. The task function loops forever and never returns.
- Start scheduling with vTaskStartScheduler(), which does not return. Higher priority number means higher priority; idle task is priority 0.
- FreeRTOS uses preemptive priority scheduling with round-robin time slicing among equal-priority ready tasks. Task states: Running, Ready, Blocked, Suspended.
- Use vTaskDelay inside tasks, not HAL_Delay busy waits. Keep ISRs short and signal a task using a queue or semaphore.
For detail: Notes pages 59–60 (opens in a new tab)
- 15
Writing to and Reading from an SPI EEPROM
Short note
- An SPI EEPROM is non-volatile memory. STM32 is the SPI master; the EEPROM is the slave. Lines: SCK, MOSI, MISO, CS. SPI mode (CPOL, CPHA) must match the datasheet.
- Write steps: send WREN (Write Enable) as its own CS-low transaction, then CS low, WRITE command, address, data, CS high. The EEPROM then runs an internal write cycle.
- After a write, poll the status register until WIP (Write In Progress) is 0. WEL (Write Enable Latch) shows if writing is enabled.
- Read steps: CS low, READ command, address, then clock in data on MISO, CS high. Reads need no write enable and can run sequentially.
- HAL calls: HAL_SPI_Transmit, HAL_SPI_Receive, HAL_SPI_TransmitReceive, with CS driven by HAL_GPIO_WritePin. Command codes and address size depend on the chip.
For detail: Notes pages 39–45 (opens in a new tab)
- 16
ARM Addressing Modes & Instruction Set (Thumb, Thumb-2)
Short note
- An addressing mode says where an instruction finds its operand: in the instruction, in a register, or in memory.
- Four modes: immediate (MOV R0, #10), register (ADD R2, R0, R1), indexed or register-indirect (LDR R0, [R1, #4]), PC-relative (B LOOP, BL func).
- Register addressing is fastest, with no memory access. PC-relative gives relocatable code and is used for branches and nearby constants.
- Instruction types: arithmetic (ADD, SUB, MUL), logical (AND, ORR, EOR), data transfer (LDR, STR, MOV), branch (B, BL, BX).
- Thumb is 16-bit for small code size. Thumb-2 mixes 16-bit and 32-bit instructions for good density plus performance, and is used by Cortex-M. Cortex-M runs only Thumb state.
For detail: Notes pages 51–54 (opens in a new tab)
- 17
FreeRTOS Queues, Semaphores, Timers and Delays
Short note
- Queues pass data between tasks: xQueueCreate(length, item size), xQueueSend(q, &item, ticks), xQueueReceive(q, &buf, ticks). A task blocks until timeout when empty or full.
- Binary semaphore is a signal (0 or 1) used to sync a task with an ISR. Counting semaphore holds a count for events or resource pools. Mutex protects shared data with priority inheritance.
- Use xSemaphoreGiveFromISR(sem, &woken) inside interrupts, then portYIELD_FROM_ISR(woken). Task side uses xSemaphoreTake(sem, timeout).
- vTaskDelay(n) waits n ticks from the call, so period drifts. vTaskDelayUntil(&last, n) gives a fixed period. pdMS_TO_TICKS converts ms to ticks.
- Software timers (xTimerCreate, xTimerStart) run callbacks from the timer service task, either one-shot or auto-reload. Callbacks must not block.
For detail: Notes page 59 (opens in a new tab)
- 18
ADC on STM32: Conversion, Resolution & Potentiometer
Short note
- An ADC converts a continuous analog voltage into a proportional binary number. STM32U575 ADC1 is 14-bit but is usually set to 12-bit, so 0 to 3.3 V maps to 0 to 4095.
- Conversion steps: sample and hold, quantize to the nearest level, encode to binary, send the digital output to the CPU.
- Digital value = Vin x 4095 / Vref, so Vin = value x Vref / 4095. Step size (LSB) = Vref / 4096, about 0.8 mV at 3.3 V.
- HAL polling sequence: HAL_ADC_Start(&hadc1); HAL_ADC_PollForConversion(&hadc1, 10); val = HAL_ADC_GetValue(&hadc1);
- Potentiometer: a 3-terminal voltage divider. Ends go to 3.3 V and GND, the wiper gives 0 V to 3.3 V (about 1.65 V mid, ADC about 2048) into an ADC pin.
- STM32 ADC also supports interrupt mode, DMA and multiple channels, with low power operation.
For detail: Notes pages 66–69 (opens in a new tab)
- 19
ARM and the Cortex-M Series: Overview, Features & Applications
Short note
- ARM Ltd designs and licenses RISC processor cores. It does not make chips. STMicro, NXP and TI build microcontrollers (such as STM32) around ARM cores.
- Cortex-M is a family of 32-bit ARM cores for microcontrollers. M stands for Microcontroller. Optimised for low power, small size, low cost, fast interrupts and real-time operation.
- Cortex-M was created because one processor cannot serve both a simple thermometer and an industrial robot. The family scales cost, power and performance.
- Evolution: Armv6-M (M0, M0+, M1), Armv7(E)-M (M3, M4, M7), Armv8-M (M23, M33).
- Key features: Thumb-2, NVIC, SysTick, low-power sleep modes, optional MPU, and optional FPU, DSP and TrustZone in newer cores.
For detail: Notes page 3 (opens in a new tab), Notes page 19 (opens in a new tab), Notes page 22 (opens in a new tab)
- 20
SPI Protocol: Signals, CPOL/CPHA Modes, Multi-Slave
Short note
- SPI is a synchronous, full-duplex master-slave serial bus with four lines: SCLK (from master), MOSI (master to slave), MISO (slave to master) and SS/CS (slave select, active low).
- Each clock pulse shifts one bit out and one bit in, so send and receive happen together. Bit order is MSB first or LSB first, as configured.
- CPOL sets the idle level of the clock (0 low, 1 high). CPHA picks the sampling edge (0 first edge, 1 second edge). Mode 0 is 0,0; Mode 1 is 0,1; Mode 2 is 1,0; Mode 3 is 1,1.
- Multi-slave: share SCLK, MOSI and MISO, and give each slave its own CS line. The master pulls only one CS low at a time.
- Pros: fast, simple, no addressing. Cons: more wires than I2C, one CS per slave, no ACK, short distance only.
For detail: Notes pages 24–25 (opens in a new tab)
- 21
CAN Communication between STM32U575 Boards
Short note
- Each STM32U575 connects through a CAN transceiver to the CANH and CANL bus, with 120 ohm termination resistors at both ends. The transceiver turns TX/RX logic into differential signals.
- Setup steps: enable the CAN peripheral, set TX/RX alternate-function pins, set bit timing (prescaler, TSEG1, TSEG2, SJW) for a rate such as 500 kbit/s, choose mode, set filters, start.
- All nodes must use the same bit rate. Normal mode is for operation; loopback mode is for testing. The STM32U575 CAN peripheral is FDCAN, which also handles classical CAN.
- Acceptance filters pass only wanted IDs, for example accept 0x100 and 0x200 and reject 0x300. This reduces CPU load.
- Transmit: fill an FDCAN_TxHeaderTypeDef (Identifier, IdType, TxFrameType, DataLength) and up to 8 data bytes, call HAL_FDCAN_AddMessageToTxFifoQ. Receive: HAL_FDCAN_GetRxMessage from Rx FIFO0.
For detail: Notes pages 46–51 (opens in a new tab)
- 22
Timer-Based Real-Time Clock (RTC) and Alarms
Short note
- The RTC keeps date and time. It runs from a low-power clock (32.768 kHz LSE) and keeps counting through low-power modes and on a backup battery (VBAT).
- Uses: clocks, calendars, data logging, smart meters, and waking the MCU from Stop or Standby with an alarm or wakeup timer.
- Timer-based RTC idea: a timer overflows or interrupts every 1 s and the ISR increments seconds, minutes, hours and the date.
- HAL calls: HAL_RTC_SetTime(), HAL_RTC_SetDate(), HAL_RTC_GetTime(), HAL_RTC_GetDate(), HAL_RTC_SetAlarm_IT(). Time values are BCD or binary format.
- Alarm fires an interrupt when time matches the set value. Read the date after the time, or the time registers stay locked.
For detail: Notes page 24 (opens in a new tab), Notes page 32 (opens in a new tab), Notes page 35 (opens in a new tab)
- 23
Implementing TrustZone on STM32U575: GTZC, Peripheral Security, Secure Boot
Short note
- The STM32U575 has TrustZone. GTZC (Global TrustZone Controller) sets and enforces security attributes for peripherals and memories.
- GTZC has TZSC (TrustZone Security Controller), TZIC (TrustZone Illegal Access Controller) and MPCBB (block-based memory protection controller for SRAM).
- TZSC marks each peripheral Secure or Non-secure, so a UART can be reserved for Secure code. TZIC reports illegal accesses as flags and interrupts.
- Option bytes enable TrustZone (TZEN=1). Flash and SRAM security regions are set through SAU, option bytes (SECWM) and MPCBB.
- Secure boot checks the firmware signature and integrity before running it. If the check fails, the device rejects the image or recovers by policy.
For detail: Notes page 49 (opens in a new tab), Notes page 58 (opens in a new tab)
- 24
ARM Processor Core Components: Register File, ALU, Barrel Shifter, Multiplier
Short note
- Core blocks: register file, ALU, barrel shifter, multiplier, instruction decode and control unit, address register with incrementer, and address and data buses.
- Register file: R0 to R12 general purpose, R13 = SP, R14 = LR, R15 = PC. Register access is far faster than memory.
- ALU does add, subtract, AND, OR, XOR and compares. One input comes from the register file, the other from the barrel shifter, and results can update the flags.
- Barrel shifter shifts or rotates an operand (LSL, LSR, ASR, ROR) before the ALU, so a shift and an operation take one instruction. The multiplier keeps the low 32 bits unless a long multiply is used.
- Correction: the notes name a 17th register CPSR (classic ARM7). Cortex-M has no CPSR; its status register is xPSR with flags N, Z, C, V.
For detail: Notes pages 23–24 (opens in a new tab)
- 25
ARM TrustZone: Architecture, Secure and Non-Secure States, Memory Partitioning
Short note
- ARM TrustZone is hardware security on Cortex-M23 and M33 that splits the CPU into Secure and Non-secure states. Keys and trusted code stay in Secure; the app runs in Non-secure.
- Secure handles secure boot, crypto, key storage and authentication. Non-secure handles the application, UI and network stack, and cannot freely access Secure resources.
- Memory is split into Secure, Non-secure and Non-secure Callable (NSC) regions. SAU and IDAU set the attribute of each address. Flash and SRAM can each be partitioned.
- Non-secure code enters Secure only through an NSC region, where the SG (Secure Gateway) instruction must be the first instruction of each entry point.
- Return to Non-secure uses BXNS. Secure functions are entry points marked cmse_nonsecure_entry, and Non-secure code calls them like normal functions.
For detail: Notes pages 46–47 (opens in a new tab), Notes pages 51–54 (opens in a new tab)
- 26
Timers and Counters: Prescaler, ARR & Timer Configuration
Short note
- A timer is a hardware counter driven by a clock. It makes delays, counts events, measures pulse width (input capture), compares (output compare) and generates PWM.
- Timer clock after prescaler = fclk / (PSC + 1). Overflow or update frequency = fclk / ((PSC + 1) x (ARR + 1)). Example: 80 MHz, PSC 7999, ARR 9999 gives 1 Hz.
- PSC (prescaler) divides the clock. ARR (auto-reload) is the count limit. The counter counts 0 to ARR, then sets the update event and reloads.
- HAL: HAL_TIM_Base_Start_IT(&htim2) starts the timer with an interrupt. The ISR calls HAL_TIM_PeriodElapsedCallback(htim).
- As a counter, the timer counts external pulses on its input pin (external clock mode) instead of the internal clock. Use it to count events or measure frequency.
For detail: Notes pages 17–18 (opens in a new tab), Notes page 24 (opens in a new tab), Notes page 31 (opens in a new tab)
- 27
CAN Protocol: Frame Format, Arbitration, Error Detection
Short note
- CAN is a multi-master, message-based serial bus on a two-wire differential pair (CANH and CANL). It has high noise immunity and is used in cars and industry.
- Classical CAN data frame: SOF, identifier, RTR, control field (IDE, DLC), data (0 to 8 bytes), CRC, ACK, EOF, then inter-frame space.
- Arbitration is non-destructive and bitwise. Dominant bit is 0 and recessive is 1; dominant wins the bus. Lower ID means higher priority. A node sending recessive but seeing dominant stops.
- Error detection: bit monitoring, bit stuffing (a bit of opposite value after five equal bits), CRC, frame check and ACK check.
- On error the node sends an error frame and the message is retransmitted automatically. Nodes keep error counters and can go bus-off.
For detail: Notes pages 30–32 (opens in a new tab)
- 28
ARM Cortex-M Memory Architecture & Memory Map
Short note
- A memory map assigns fixed address ranges to code, SRAM, peripherals and system control. Cortex-M has one 32-bit space, 0x00000000 to 0xFFFFFFFF (4 GB).
- Main regions: Code (Flash) 0x00000000, SRAM 0x20000000, Peripherals 0x40000000, external RAM 0x60000000, system and PPB (NVIC, SysTick, SCB) 0xE0000000.
- Flash: non-volatile, holds the program. SRAM: volatile and fast, holds variables, stack, heap. EEPROM: non-volatile, small, for configuration data.
- Stack: LIFO, automatic, holds locals, call info and return addresses, grows downward. Heap: dynamic memory with malloc() and free(), programmer-managed.
- Peripheral registers are memory-mapped, so a read or write at a peripheral address controls the hardware directly.
For detail: Notes pages 48–49 (opens in a new tab)
- 29
USB HID: Enumeration, Descriptors, Keyboard/Mouse Emulation
Short note
- HID (Human Interface Device) is a USB class for keyboards, mice and joysticks. Hosts have built-in HID drivers, so no custom driver is needed. STM32 runs as a USB device.
- Enumeration: device attached, host detects and resets it, requests descriptors, assigns a USB address, selects a configuration, then the HID interface is ready.
- Descriptors: device (VID, PID, class, max packet size), configuration, interface (class HID), HID descriptor, endpoint (number, direction, type, interval) and report descriptor.
- The report descriptor defines the data format. A keyboard report is 8 bytes: 1 modifier, 1 reserved, 6 key codes. A mouse report holds buttons, X, Y and wheel.
- Reports go to the host on an interrupt IN endpoint, polled at a fixed interval. Send a key press report, then an all-zero release report. Use USBD_HID_SendReport.
For detail: Notes pages 54–62 (opens in a new tab)
- 30
Cortex-M23 vs Cortex-M33: Block Diagrams, Baseline vs Mainline
Short note
- Cortex-M23 implements Armv8-M Baseline: ultra-low power, small area, for simple IoT, sensors and wearables. Cortex-M33 implements Mainline: higher performance, for advanced secure IoT.
- Both have NVIC, with TrustZone, MPU and SysTick as options. TrustZone works the same way on both; M33 adds extras such as stack limit checking in both security states.
- Extra in M33: optional DSP extension and FPU, ITM and ETM trace options, and a coprocessor interface. M23 has no DSP or FPU. Both have the same 4 GB address space.
- Comparison: M23 = Baseline, simpler, 2-stage pipeline, lowest power. M33 = Mainline, 3-stage pipeline, higher performance. M33 is a superset of M23 features.
- STM32U575 uses Cortex-M33 at up to 160 MHz.
For detail: Notes page 43 (opens in a new tab), Notes pages 63–64 (opens in a new tab)
- 31
16x2 LCD Interfacing in 4-bit Mode
Short note
- 16x2 LCD shows 16 characters on each of 2 rows, 32 in total. It has 16 pins: VSS, VDD, VEE (contrast), RS, RW, EN, D0 to D7, LED+ and LED-.
- RS = 0 selects the command register, RS = 1 selects the data register. RW = 0 write, RW = 1 read; RW is usually tied to GND. EN latches data on a high-to-low pulse.
- 4-bit mode uses only D4 to D7, saves GPIO pins and is most common. Each byte is sent as two nibbles. 8-bit mode uses D0 to D7 and needs more pins.
- Commands: 0x01 clear display, 0x02 return home, 0x0C display on cursor off, 0x80 first row start, 0xC0 second row start. Common 4-bit setup uses 0x28.
- Example connections: RS PA0, EN PA1, D4 to D7 PA2 to PA5. Then LCD_SetCursor and LCD_Print("HELLO"). Limits: few characters, needs several pins.
For detail: Notes pages 51–53 (opens in a new tab)
- 32
Debugging Strategies, Tools and Processor Faults
Short note
- Faults: HardFault (catch-all), MemManage (MPU violation), BusFault, UsageFault (undefined instruction, invalid state, divide by zero if trapping is on), SecureFault on M33. Disabled ones escalate to HardFault.
- CFSR (Configurable Fault Status Register) holds the MMFSR, BFSR and UFSR bits. HFSR flags HardFault causes. MMFAR and BFAR hold the faulting address.
- On a fault the CPU stacks R0-R3, R12, LR, PC and xPSR. The stacked PC usually points to the faulting instruction (not for imprecise bus faults), so read it in a HardFault handler.
- Debug with SWD (2-pin debug port: SWDIO, SWCLK) using ST-LINK, breakpoints (stop at code address) and watchpoints (stop when a variable is read or written).
- ITM and SWO give printf-style trace output without a UART. Also use a serial terminal, LEDs, logic analyser and single-step. Use unit tests.
- 33
I2C Protocol: START/STOP, Addressing, ACK, Clock Stretching
Short note
- I2C is a two-wire, synchronous, half-duplex bus: SDA (data) and SCL (clock). Lines are open-drain, so each needs a pull-up resistor. The master generates SCL.
- START: SDA goes high to low while SCL is high. STOP: SDA goes low to high while SCL is high. Data changes only while SCL is low.
- Transfer order: START, 7-bit slave address, R/W bit (0 write, 1 read), ACK, data byte, ACK, STOP. ACK means the receiver pulls SDA low; NACK means SDA stays high.
- Each slave has an address (7-bit common, 10-bit also possible), so no chip-select lines are needed. Speeds: Standard 100 kbit/s, Fast 400 kbit/s, Fast Mode Plus 1 Mbit/s.
- Clock stretching: a slave holds SCL low to make the master wait until it is ready. Multi-master is allowed with arbitration.
For detail: Notes pages 16–18 (opens in a new tab)
- 34
Cortex-A vs Cortex-M Processors
Short note
- Cortex-A is an application processor: GHz clocks, multi-core, MMU, runs Linux or Android, large DDR RAM. Examples: Raspberry Pi, smartphones.
- Cortex-M is a microcontroller core: MHz clocks, low power, deterministic real-time response, runs bare-metal or RTOS. Examples: STM32, NXP LPC.
- Cortex-M has small SRAM and Flash, fast boot, fast NVIC interrupts and low cost. Cortex-A has high cost, higher power and longer boot.
- Comparison in one line: Cortex-A trades power and cost for performance and an OS. Cortex-M trades speed for low power, low cost and real-time control.
- Use Cortex-M for sensors, IoT and automation. Use Cortex-A for AI, robotics, multimedia and smartphones.
For detail: Notes page 58 (opens in a new tab), Notes pages 61–63 (opens in a new tab)
- 35
Matrix Keypad Interfacing
Short note
- A matrix keypad arranges keys in rows and columns, so a 4x4 keypad (16 keys) needs only 8 GPIO pins instead of 16.
- Scanning: drive one row LOW at a time and read the columns. A column reading LOW tells you which key in that row is pressed.
- Rows are set as outputs, columns as inputs with pull-ups (internal pull-up or resistors). Key row and column together identify the key.
- Add a short debounce delay (about 10 to 20 ms) so one press is read once.
- Types: 3x4 and 4x4 keypads. The 4x4 layout is 1 2 3 A, 4 5 6 B, 7 8 9 C, * 0 # D.
For detail: Notes page 54 (opens in a new tab)
- 36
Code and Memory Optimization Techniques
Short note
- Compiler optimisation levels: -O0 none (easy to debug), -O1, -O2 speed, -O3 most speed (bigger code), -Os smaller size. Embedded builds often use -Os.
- Put constant tables in flash with const rather than RAM. Use smaller types (uint8_t, uint16_t) and a suitable data width instead of int everywhere.
- inline removes call overhead but grows code. Loop unrolling is faster but larger, so it trades size for speed.
- Use DMA for bulk transfers to free the CPU, and the lowest suitable clock and sleep modes for power.
- Avoid dynamic allocation (malloc and free) because of fragmentation and unpredictable timing. Use static buffers or memory pools and avoid recursion and large stack arrays.
- 37
Interrupt Handling on STM32: Polling vs Interrupts, NVIC, EXTI
Short note
- An interrupt is a signal that pauses the main program so the CPU can run an ISR for an urgent event, then returns to where it left off.
- Polling: CPU keeps checking a flag in a loop. It wastes CPU time and responds slowly. Interrupt: hardware tells the CPU, giving fast response and free CPU time.
- NVIC (Nested Vectored Interrupt Controller) assigns priorities, lets higher priority preempt lower, and jumps via the vector table for fast response.
- EXTI handles pin interrupts on rising or falling edges. Enable with HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ(). STM32U5 callbacks: HAL_GPIO_EXTI_Rising_Callback(), HAL_GPIO_EXTI_Falling_Callback().
- Keep ISRs short and mark variables shared with the main code as volatile.
For detail: Notes page 13 (opens in a new tab)
- 38
Interfacing an I2C Temperature Sensor and Displaying on an LCD
Short note
- STM32 is the I2C master and the sensor (for example LM75) is the slave. SDA and SCL need pull-up resistors. A 16x2 LCD can sit on the same bus through a PCF8574 I/O expander.
- Read sequence: START, slave address with write bit, ACK, temperature register address, ACK, repeated START with read bit, read data bytes, NACK on the last byte, STOP.
- Raw sensor bits are converted to degrees Celsius in software, for example 28.5 C, then printed on the LCD.
- Program flow: HAL_Init, SystemClock_Config, MX_GPIO_Init, MX_I2C1_Init, LCD_Init, then loop: read temperature, clear LCD, set cursor, print, HAL_Delay(1000).
- HAL calls for I2C: HAL_I2C_Master_Transmit, HAL_I2C_Master_Receive, or HAL_I2C_Mem_Read. The slave address is passed shifted left by 1 in HAL.
For detail: Notes pages 35–38 (opens in a new tab)
- 39
LoRa and LoRaWAN Communication
Short note
- LoRa (Long Range) is a low-power wide-area radio that uses chirp spread spectrum modulation. It is designed for long range and small payloads, not high data rate.
- LoRaWAN is the network protocol on top of LoRa: end devices talk to gateways, which forward packets over IP to a network server and then applications.
- Typical uses: smart agriculture, metering, environmental monitoring and asset tracking, where a node sends a few bytes occasionally on battery.
- LoRa vs GSM vs Bluetooth: LoRa has long range, very low power and low data rate. GSM has wide coverage, higher power and higher rate. Bluetooth has short range and low power.
For detail: Notes page 40 (opens in a new tab), Notes pages 43–45 (opens in a new tab)
- 40
Cortex-M23/M33 Compared with Previous Cortex-M Generations
Short note
- Cortex-M0, M0+ and M1 use Armv6-M: low cost, low power, for simple sensors and wearables. Cortex-M3, M4 and M7 use Armv7(E)-M: higher performance.
- M3 is general control. M4 adds DSP and optional FPU for motor control and signal processing. M7 is the highest performance, for robotics and edge AI.
- Armv8-M (M23, M33) adds TrustZone security and splits into Baseline (M23) and Mainline (M33).
- Cortex-M23 is the TrustZone successor to M0 and M0+. Cortex-M33 is the TrustZone successor to M3 and M4.
- Evolution in one line: v6-M basic and low power, v7-M performance and DSP, v8-M adds security.
For detail: Notes page 22 (opens in a new tab), Notes page 36 (opens in a new tab), Notes page 43 (opens in a new tab)
- 41
STM32 Family, Series & STM32 vs 8-bit Microcontrollers
Short note
- STM32 is a family of 32-bit microcontrollers from STMicroelectronics (ST = STMicroelectronics, M = microcontroller, 32 = 32-bit) built on ARM Cortex-M cores.
- Series: F0 (M0, entry), F1 (M3, general), F3 (M4, mixed-signal), F4 (M4, DSP and FPU), F7 (M7), H7 (highest performance), L (ultra-low power), G (general, efficient), U5 (M33, low power and secure).
- Common peripherals: GPIO, timers, ADC, DAC, UART, SPI, I2C, CAN, USB, Ethernet, plus Flash and SRAM on chip.
- STM32 vs 8-bit MCUs (8051, AVR, PIC): 32-bit core, much higher clock (tens to hundreds of MHz), more memory and peripherals, DMA, NVIC, with CubeIDE and HAL tools.
- Scalable: code moves easily between STM32 devices. Typical uses: industrial, robotics, medical, consumer, IoT, automotive.
For detail: Notes pages 2–7 (opens in a new tab)
- 42
GSM Interfacing: Call, SMS and Internet with AT Commands
Short note
- The STM32 talks to a GSM module (SIM800 or SIM900 class) over UART using AT commands, which are text commands sent to a modem. It needs a SIM card, antenna and enough supply current.
- Start with AT and expect OK. Check SIM and network with AT+CPIN? and AT+CREG?.
- Voice call: dial with ATD<number>; and hang up with ATH. Monitor the response and call status.
- SMS: set text mode with AT+CMGF=1, set the number with AT+CMGS="number", send the text, then end with Ctrl+Z (0x1A). Wait for the +CMGS response.
- Internet uses GPRS: attach with AT+CGATT=1, set the APN (AT+CSTT or AT+SAPBR), bring up the link (AT+CIICR), then open TCP with AT+CIPSTART. Use a state machine with timeouts, not blocking.
For detail: Notes pages 32–34 (opens in a new tab)
- 43
Armv8-M Architecture: Block Diagram and Core Components
Short note
- Armv8-M is the architecture behind Cortex-M23 (Baseline) and Cortex-M33 (Mainline). Its big addition is TrustZone security.
- Components: processor core, TrustZone, NVIC, memory system, MPU, AMBA bus, SysTick timer, debug and trace unit.
- TrustZone splits the system into Secure and Non-Secure worlds. Each access is checked, so keys and secure boot code stay protected.
- Working: fetch from Flash, decode and execute, transfer data over AMBA, TrustZone security check, NVIC handles interrupts, store result.
- SysTick is a built-in 24-bit down-counter timer giving periodic ticks for delays and RTOS scheduling. NVIC gives fast, priority-based interrupts.
For detail: Notes page 31 (opens in a new tab), Notes page 35 (opens in a new tab)
- 44
Embedded C Register Bit Manipulation & the volatile Qualifier
Short note
- Set a bit: REG |= (1<<n). Clear a bit: REG &= ~(1<<n). Toggle: REG ^= (1<<n). Test: if (REG & (1<<n)).
- STM32 example: GPIOA->ODR ^= (1<<5) toggles PA5. On the STM32U575, RCC->AHB2ENR1 |= RCC_AHB2ENR1_GPIOAEN turns on the GPIOA clock.
- volatile tells the compiler a variable can change outside program flow (hardware registers, ISR flags, sensor status), so it must re-read it every time. Example: volatile int sensorValue;
- const makes a read-only variable. Hardware registers are often declared volatile uint32_t *.
- Prefer fixed-width types uint8_t, uint16_t, uint32_t: known size, portable, match peripheral registers, easy bit handling.
For detail: Notes pages 13–15 (opens in a new tab)
- 45
STM32U575 Power Management & Low-Power Modes
Short note
- STM32U575 low-power software: STM32CubeU5 package (HAL, LL, middleware, examples), HAL, LL, PWR, RCC, RTC, LPTIM, DMA and CubeMX power configuration.
- HAL sleep calls: HAL_PWR_EnterSLEEPMode(), HAL_PWR_EnterSTOPMode(), HAL_PWREx_EnterSTOP2Mode(), HAL_PWR_EnterSTANDBYMode(). HAL_SuspendTick() and HAL_ResumeTick() control SysTick.
- Mode depth: Sleep stops only the CPU clock. Stop 0 to 3 keep SRAM and registers with the main clocks off. Standby loses most state. Shutdown is lowest. Deeper modes save more but wake slower.
- Wake-up sources: HAL_PWR_EnableWakeUpPin(), EXTI pins, RTC alarm, and LPTIM, which runs in Stop mode.
- Saving power: gate unused clocks (__HAL_RCC_GPIOA_CLK_DISABLE()), lower the clock and voltage scaling, and use DMA so the CPU can sleep.
For detail: Notes pages 33–37 (opens in a new tab)
- 46
Bluetooth Communication Basics (Classic and BLE)
Short note
- Bluetooth is a short-range wireless standard in the 2.4 GHz ISM band. Classic suits higher-throughput serial or audio use; BLE suits low-power sensing and control.
- BLE uses a client/server model. Data is organised as services, characteristics and descriptors. Notifications push updates without polling.
- STM32 connects to a Bluetooth module over UART (for example HC-05 for Classic serial), or over SPI or USB for other modules.
- Example flow: STM32 reads a temperature each second, updates a BLE characteristic, and the phone subscribes to notifications and shows the value.
- Classic vs BLE in one line: Classic gives higher throughput with more power; BLE gives low power with small, infrequent data.
For detail: Notes pages 37–38 (opens in a new tab)
- 47
STM32U575 Architecture, Features & Specifications
Short note
- STM32U575 is an ultra-low-power STM32U5 series MCU from STMicroelectronics on an Arm Cortex-M33 core (Armv8-M) running up to 160 MHz.
- Core features: MPU, FPU, DSP instructions, TrustZone and fast NVIC interrupts. Memory is up to 2 MB Flash and 786 KB SRAM.
- Security: TrustZone, secure boot, secure firmware update, HASH (SHA) hardware, TRNG and tamper detection. AES and PKA crypto accelerators are on the sister STM32U585, not the U575.
- Peripherals: one 14-bit and one 12-bit ADC, 12-bit DAC, timers and LPTIM, RTC, watchdogs, UART, SPI, I2C, FDCAN (CAN FD) and USB. Many are low power.
- Applications: IoT, wearables, smart meters, medical devices, industrial monitoring and battery-powered products.
For detail: Notes page 19 (opens in a new tab), Notes pages 25–26 (opens in a new tab)
- 48
Embedded C: C vs Embedded C, Program Structure, while(1) & Data Types
Short note
- Embedded C is standard C with extra focus on direct hardware access, tight memory use, fast execution and real-time timing. It is used to write firmware.
- C vs Embedded C: general computers vs embedded systems; limited vs direct hardware access; memory and timing are less vs very critical.
- Program structure: header files, macro definitions, global variables, main(), with initialisation first and then an endless while(1) loop.
- while(1) is used because firmware must never end. It keeps reading inputs and driving outputs forever, and there is no OS to return to.
- Data types: char 1 byte, int 2 or 4 bytes, float 4, double 8. Fixed-width uint8_t, uint16_t, uint32_t are preferred because plain int size varies by compiler.
For detail: Notes page 11 (opens in a new tab), Notes page 15 (opens in a new tab)
- 49
Designing an IoT-Based Home Automation System
Short note
- A home automation node is an STM32 with sensors (temperature, light, motion), actuators (relays for lights, fans, locks) and a wireless link such as Wi-Fi, BLE or GSM.
- With MQTT, the STM32 publishes sensor readings to topics and a broker forwards them to a phone app or controller. The app publishes commands that the STM32 subscribes to.
- Control flow: read sensor, compare with threshold, drive a relay through a GPIO pin with a transistor or optocoupler driver, then publish the new state.
- CoAP alternative: a client sends a PUT to change a setpoint and the device returns a response code saying if it was accepted.
- Design points: low power, secure authentication and encryption, reliable reconnect, and an RTOS to separate sensing, control and network tasks.
For detail: Notes page 28 (opens in a new tab)
- 50
Embedded Systems: Definition, Block Diagram, Characteristics & Applications
Short note
- An embedded system is a computer system built for a dedicated function inside a larger electronic or mechanical system. Examples: washing machine, car ECU, fitness band.
- Characteristics: dedicated function, real-time operation, compact size, low power, high reliability, low cost.
- Block diagram: input unit (sensors, switches), processor or controller, memory, output unit (actuators, displays, relays), power supply, and a communication interface.
- Working: sensors feed the microcontroller, it runs the program and decides, then drives outputs. For example, an automatic fan reads temperature and switches the fan.
- Applications: consumer appliances, automotive, medical devices, industrial control, IoT and wearables.
For detail: Notes pages 6–7 (opens in a new tab), Notes pages 10–11 (opens in a new tab)
- 51
STM32CubeIDE and the HAL Library
Short note
- An IDE gives editor, compiler, debugger and flashing in one tool. STM32CubeIDE is ST's official IDE with GCC, ST-LINK debug, CubeMX graphical setup and code generation.
- Workflow: new project, select the MCU, configure pins and peripherals graphically, generate init code, write app code, build, download to the board, debug.
- HAL (Hardware Abstraction Layer) is a software layer between the application and peripheral registers. It gives ready-made APIs so you avoid register-level code.
- HAL examples: HAL_Init(), HAL_GPIO_WritePin(), HAL_GPIO_TogglePin(), HAL_Delay(), HAL_UART_Transmit(), HAL_ADC_Start(). Modules: HAL_GPIO, UART, SPI, I2C, ADC, TIM, DMA, RTC.
- IDE builds and flashes the code. HAL runs on the chip and turns function calls into register operations. LL drivers are the lighter, faster alternative.
For detail: Notes page 39 (opens in a new tab), Notes page 42 (opens in a new tab)
- 52
Classification of Processors: RISC vs CISC, Harvard vs Von Neumann, Pipelining
Short note
- RISC uses a small set of simple, fixed-length instructions, mostly single cycle, which suits pipelining. CISC uses many complex, variable-length instructions. Cortex-M is RISC.
- Harvard architecture has separate instruction and data memories and buses, so fetch and data access happen together. Von Neumann shares one memory and one bus for both.
- Harvard advantages: no bus conflicts, simultaneous instruction fetch and data access, faster. Von Neumann is simpler but has a bottleneck on the single bus.
- Pipelining overlaps instruction stages. Three stages: Fetch, Decode, Execute. While ADD executes, SUB is decoded and CMP is fetched.
- Pipelining raises throughput to about one instruction per clock, cuts CPU idle time and keeps power low.
For detail: Notes pages 25–28 (opens in a new tab)
- 53
DAC on STM32: Simple Output, Sine Wave & Audio Generation
Short note
- A DAC converts a digital value to an analog voltage. For a 12-bit DAC, Vout = Vref x value / 4095, with 0 giving 0 V and 4095 giving full scale.
- HAL steps: HAL_DAC_Start(&hdac1, DAC_CHANNEL_1); HAL_DAC_SetValue(&hdac1, DAC_CHANNEL_1, DAC_ALIGN_12B_R, value);
- Sine wave: store one cycle of samples in a lookup table (for example uint16_t sineTable[]), send them to the DAC at regular intervals from a timer interrupt, then smooth with a low-pass filter.
- Sine frequency = sample rate / number of samples per cycle. More samples give a smoother wave. Centre value is 2048 for a 12-bit DAC.
- Audio output works the same way: send audio sample values to the DAC at the sample rate (timer triggered, often with DMA), then filter and amplify.
For detail: Notes pages 83–84 (opens in a new tab)
- 54
Microprocessor vs Microcontroller & Popular Microcontroller Families
Short note
- Microprocessor is a CPU chip only (ALU, decoder, registers). RAM, ROM and I/O are separate external chips. Examples: Intel 8085, 8086.
- Microcontroller is a single-chip computer: CPU, RAM, ROM or Flash, I/O, timers, interrupt controller and serial port on one chip. Examples: 8051, PIC, AVR, STM32.
- Comparison: MPU is general-purpose, costly and higher power, with a flexible memory choice. MCU is control-oriented, cheap, low power and compact, with fixed on-chip memory.
- Popular families: 8051 (8-bit), Microchip PIC (8/16-bit), Atmel AVR (8-bit, Arduino), TI MSP430 (16-bit ultra-low power), ARM Cortex-M (32-bit).
- Microcontrollers are preferred for embedded work because they cut chip count, cost, size and power.
For detail: Notes pages 16–18 (opens in a new tab)
Finished the Microcontrollers list?
KTUPredict is free, with no ads and no sign-up. Made by students, for students. A chai keeps new courses coming before your exams.
Buy me a chai (opens in a new tab)What to do tonight
Pick one Part B question in each module and get solid on it: that covers 24 marks. Then learn the Part A definitions and comparisons, which are short and worth 2 marks each. Use the notes pages next to each question.
Practice paper (Set 1)
Model paper questions, regrouped. Not an official KTU paper.
Part A answer all questions
- 1
Explain the purpose of the main stack pointer (MSP) and the process stack pointer (PSP) in a Cortex-M33 processor. Which bit in the control register selects the stack pointer in thread mode?
2 marksTopic 2
- 2
Explain the Armv8-M architecture and its two profiles, Baseline and Mainline. Describe how the Cortex-M23 and Cortex-M33 processors correspond to these profiles. Discuss the additional features and capabilities provided by the Cortex-M33.
2 marksTopic 30
- 3
Write the STM32 HAL statements to toggle an LED that is connected to pin PB7 every 500 ms inside an infinite loop.
2 marksTopic 6
- 4
Explain how a 16x2 character LCD can be interfaced with an STM32 microcontroller using 4-bit mode. Describe the LCD initialization sequence and provide suitable functions for sending command and data bytes to the display.
2 marksTopic 31
- 5
Explain the USART frame format 8N1 and calculate the time, in milliseconds, required to transmit one byte at a baud rate of 9600 bits per second.
2 marksTopic 1
- 6
Explain the USB HID enumeration process for a keyboard, including how the host identifies and configures the device. Describe how a keyboard key press is reported using a HID report, and outline the steps required to implement a USB HID keyboard/mouse device on the STM32U575.
2 marksTopic 29
- 7
Identify two common security threats to IoT devices and explain the security principle or mechanism that can be employed to mitigate each threat.
2 marksTopic 7
- 8
Explain the concept of a queue in FreeRTOS and distinguish it from a counting semaphore, particularly in the context of inter-task communication and synchronization.
2 marksTopic 17
Part B answer one full question from each module
Module 1: answer one of these 2 questions
- 9a
Using a neat and well-labeled block diagram, explain the typical architecture of an ARM Cortex-M-based microcontroller. Describe the functions and roles of the CPU core, Flash memory, SRAM, bus matrix, and peripheral interfaces within the system.
3 marksTopic 5
- 9b
Explain how bit 5 of a memory-mapped 32-bit GPIOx_ODR register can be set, cleared, toggled, and tested using Embedded C macros. Also, explain the significance of the volatile qualifier when accessing hardware registers, with a suitable example.
3 marksTopic 44
or
- 10a
Explain the difference between an embedded system and a general-purpose computer. Mention any four applications of embedded systems.
3 marksTopic 50
- 10b
Explain the operating modes (Thread and Handler) and privilege levels (privileged and unprivileged) of the ARM Cortex-M processor. Describe how the CONTROL register is used to manage and switch between privileged and unprivileged execution in Thread mode.
3 marksTopic 2
Module 2: answer one of these 2 questions
- 11a
Explain how a common-cathode seven-segment display can be interfaced with an STM32 microcontroller. Provide the segment code table for displaying digits 0-3, and demonstrate how STM32 HAL-based code can be used to display a counter from 0 to 9 with a 1-second delay between successive digits.
3 marksTopic 4
- 11b
For an LDR-based voltage divider connected to the ADC input of the STM32U575, explain how the ADC can be configured and demonstrate how STM32 HAL code can read the ADC value in polling mode and activate a relay when the measured light level falls below a specified threshold.
3 marksTopic 13
or
- 12a
How does polling differ from interrupt-driven I/O, and how to configure GPIO pin in STM32 HAL as an external interrupt input?
3 marksTopic 37
- 12b
Explain the operation of a timer in counter mode and in real-time clock (RTC) mode. Describe how the STM32 RTC is configured to maintain accurate time, and explain how an alarm can be configured to generate an interrupt at a specified time.
3 marksTopic 22
Module 3: answer one of these 2 questions
- 13a
Compare the USART, I2C, SPI, and CAN communication protocols in terms of the number of wires required, communication speed, synchronous or asynchronous operation, network topology, and typical applications.
3 marksTopic 9
- 13b
Explain the differences between 7-bit and 10-bit I2C addressing, and describe the purpose and importance of pull-up resistors on the SDA and SCL lines.
3 marksTopic 33
or
- 14a
Explain how CAN communication can be configured between two STM32U575 boards. Describe how HAL code can be used to transmit a CAN data frame with the identifier 0x123 from one node and configure the other node to receive the frame using an interrupt.
3 marksTopic 21
- 14b
Explain how the USART protocol works, including its frame format, baud rate, and the functions of the start, stop, and parity bits. Also explain how HAL code can be used to receive a string from a serial terminal application in interrupt mode and echo the received string back to the terminal.
3 marksTopic 1
Module 4: answer one of these 2 questions
- 15a
Describe the different layers of IoT architecture and explain the role of each layer. Compare the MQTT and CoAP communication protocols in terms of their underlying transport protocols, communication models, and suitability for resource-constrained IoT devices.
3 marksTopic 3
- 15b
How does fault analysis help in debugging embedded systems? Mention any two common processor faults.
3 marksTopic 32
or
- 16a
Explain how FreeRTOS can be implemented on an STM32 to create two tasks that blink two LEDs at different rates using vTaskDelay(). Also, describe how a third task can be synchronized using a binary semaphore released by a button interrupt, and explain the purpose and meaning of each parameter passed to xTaskCreate().
3 marksTopic 14
- 16b
Briefly explain the steps involved in implementing TrustZone on the STM32U575.
3 marksTopic 23
Practice paper (Set 2)
More practice questions, not past papers. Not an official KTU paper.
Part A answer all questions
- 1
Compare Harvard and Von Neumann computer architectures. State why Harvard architecture is preferred in ARM Cortex-M microcontrollers.
2 marksTopic 52
- 2
What is the xPSR (program status register) of a Cortex-M processor and what does it store? Name its condition flags.
2 marksTopic 10
- 3
Mention two low-power modes available in the STM32 microcontroller and briefly explain how each mode achieves reduced power consumption.
2 marksTopic 45
- 4
What is a DAC? Write the STM32 HAL statements to output 1.65 V on channel 1 of a 12-bit DAC with a 3.3 V reference.
2 marksTopic 53
- 5
Define CPOL and CPHA. List the four SPI modes.
2 marksTopic 20
- 6
Differentiate synchronous USART and asynchronous UART modes. Explain the function of hardware flow control lines (RTS and CTS).
2 marksTopic 1
- 7
List any four code or memory optimization techniques used in embedded firmware and state the benefit of each.
2 marksTopic 36
- 8
Contrast LoRaWAN with cellular GSM in terms of range, battery life, data rate, and operating frequency bands.
2 marksTopic 39
Part B answer one full question from each module
Module 1: answer one of these 2 questions
- 9
Explain the structure of an Embedded C program with a neat diagram.
6 marksTopic 48
or
- 10
Compare the Cortex-M33 processor with previous ARM Cortex-M generations (Cortex-M3 and Cortex-M4). Highlight improvements in security, DSP performance, and bus architecture.
6 marksTopic 40
Module 2: answer one of these 2 questions
- 11
Explain the architecture and key features of the STM32U575 microcontroller. Discuss how the STM32CubeIDE and HAL libraries simplify peripheral configuration and cross-platform embedded firmware development.
6 marksTopic 47
or
- 12
Explain how a sine wave can be generated using the DAC of an STM32 microcontroller with a lookup table, and write the HAL code for it. How can the same approach be extended to generate an audio signal?
6 marksTopic 53
Module 3: answer one of these 2 questions
- 13
Explain the complete byte transfer sequence on an I2C bus including START, 7-bit slave address, R/W bit, ACK/NACK generation, data byte transfer, and STOP condition with timing diagrams.
6 marksTopic 33
or
- 14
Explain the write and read operations of an SPI EEPROM, including WREN, status register and the HAL code.
6 marksTopic 15
Module 4: answer one of these 2 questions
- 15
Explain how an STM32 microcontroller can be interfaced with a GSM module using AT commands to send sensor alert SMS and establish an HTTP connection.
6 marksTopic 42
or
- 16
Design an IoT-based home automation system using an STM32 microcontroller. Draw the block diagram and explain how the sensors, relays, wireless module and an MQTT broker work together.
6 marksTopic 49
How sure are we?
First exam: there is no past paper to test the ranking against, so there is no score.
Official papers used (1): Model paper.
Generated 2026-11-29. Forecasts are predictions: use them to decide what to read first, not what to skip.