The Essence of Embedded Systems – Firmware Edition (STM32 Discovery Board)

If you’ve understood the overall flow in *The Essence of Embedded Systems – Fundamentals*, it’s now time to implement STM32 firmware yourself. Using an STM32 Discovery Board, you’ll systematically learn everything from CubeMX configuration to implementing firmware based on GPIO, UART, timers, and interrupts. This course goes beyond simply using HAL APIs, covering how to connect peripherals and design systems within a real project workflow. Rather than practicing individual functions in isolation, you’ll gain hands-on experience completing an entire firmware system.

(5.0) 10 reviews

77 learners

Level Basic

Course period Unlimited

Embedded
Embedded
MCU
MCU
stm32
stm32
microcontroller
microcontroller
firmware
firmware
Embedded
Embedded
MCU
MCU
stm32
stm32
microcontroller
microcontroller
firmware
firmware

[Development Story] The code is working properly, so why isn’t the LED turning on?

Hello.
This is Huchu Dad from the Beginner Coder Rescue Team.
This time, I’d like to talk about a situation you’re likely to encounter at least once when starting firmware development.


Suppose you wrote the following code to turn on an LED on an STM32.
HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_SET);
The compilation completes successfully, and the firmware is downloaded to the board without any issues.
But if the LED does not turn on, what should you check first?


Even if the code appears to have no issues, there can be various reasons why the hardware does not work.

  • Is the GPIO clock enabled?

  • Is the pin configured as an output?

  • Is the pin number to which the actual LED is connected correct?

  • Is the LED Active High or Active Low?

For example, if the GPIO clock is not enabled, you may not get the expected behavior even when accessing the GPIO registers.
In STM32 HAL, enable the GPIO clock as follows.
__HAL_RCC_GPIOD_CLK_ENABLE();
Also, if the LED is connected in an Active Low configuration, you may need to output GPIO_PIN_RESET instead of GPIO_PIN_SET to turn it on.


Then how do actual developers solve the problem?
Rather than modifying the code haphazardly, they check the following in order.

  1. Check the LED connection through the datasheet and schematic.

  2. Check the GPIO settings in CubeMX

  3. Check whether the code is actually executing using a debugger

  4. If necessary, check the pin output with a multimeter or logic analyzer.

This process is commonly referred to as debugging that examines both hardware and software.


This week's small challenge!
Take a look at the LED control code for the STM32F4-Discovery board used in the firmware section.
What difference would occur if you changed the GPIO output mode from Push-Pull to Open-Drain?
Before changing the setting, try predicting the result first, then compare it with the actual behavior.
What matters in firmware development is not simply the ability to write code.
Understanding what behavior the code you write produces on actual hardware is an important foundation for growing as a firmware engineer.


Thank you.

From the Coding Newbie Rescue Team

Comment