Skip to main content

Check Your Understanding 1.1.4 Check Your Understanding

1.

What distinguishes a microcontroller from a general-purpose CPU (like the one in a laptop)?
  • A microcontroller integrates CPU, memory, and peripherals on one chip and is designed to run a single dedicated task with direct hardware access, whereas a general-purpose CPU relies on external chips and an operating system.
  • Correct. The all-in-one integration is what makes microcontrollers cheap, low-power, and suitable for embedded tasks, but it also means they are not easily repurposed for general computing.
  • A microcontroller is always faster than a CPU because it has no operating system overhead.
  • Microcontrollers are almost always slower than modern laptop CPUs in raw compute speed: the STM32C031C6 runs at 12 MHz versus several GHz for a laptop. The advantage is integration and low power, not raw speed.
  • A microcontroller uses a different programming language than a general-purpose processor.
  • Both are programmed in standard languages like C. The difference is in the hardware architecture and intended use, not the programming language.
  • A microcontroller can only control LEDs and buttons, while a CPU handles more complex tasks.
  • Microcontrollers handle a wide range of tasks: motor control, wireless communication, sensor fusion, and more. The distinction is not about task complexity but about integration and direct hardware access.

2.

A microcontroller has 48 physical pins. Some carry power and ground; others are GPIO. What does “general-purpose” mean in GPIO?
  • The pin has no fixed function: software configures it as either a digital input or a digital output, and the same pin can serve different roles in different projects.
  • Correct. Unlike a dedicated power pin (which is always connected to the 3.3 V supply, VDD) or a crystal pin (which is always an oscillator input), a GPIO pin’s role is determined entirely by how your code configures it.
  • The pin can carry analog signals as well as digital ones.
  • Some GPIO pins do have an analog mode, but that is a specific additional function, not what “general-purpose” means. The core meaning is software-configurable input or output.
  • The pin is usable on any microcontroller brand, not just STM32.
  • GPIO is a common concept, but “general-purpose” refers to the pin’s flexibility within one chip, not cross-brand compatibility.
  • The pin can source or sink any amount of current the connected device needs.
  • GPIO pins have strict current limits: the STM32C031C6 datasheet rates a pin for 6 mA, or 15 mA with relaxed output levels. “General-purpose” refers to input/output configurability, not unlimited current capability.

3.

You write to GPIOA->MODER to configure PA5 as an output, but the pin never responds. You have not written to RCC->IOPENR. What is the most likely explanation?
  • The GPIOA peripheral’s clock has not been enabled; writes to its registers are silently ignored until the clock is turned on via RCC.
  • Correct. The STM32 leaves peripheral clocks disabled by default. RCC->IOPENR must be set before any GPIO register is accessed.
  • The MODER register requires two writes to take effect; one write is not enough.
  • MODER takes effect on the first write, but only if the peripheral clock is already enabled. The missing step is the clock enable, not a second MODER write.
  • PA5 is reserved for the on-board LED and cannot be configured by user code.
  • PA5 is the on-board LED pin, but it is fully accessible to user code: that is what Blinky drives. No pin is “reserved” in a way that blocks user access.
  • The processor must be restarted after writing to MODER before the new mode takes effect.
  • GPIO configuration takes effect immediately on the write: no restart required. The missing step is the clock enable.