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.
77 learners
Level Basic
Course period Unlimited


[Development Story] What Is the MCU Doing When You Use HAL_Delay()?
Hello.
I'm Huchu Appa from the Coding Beginner Rescue Squad.
This time, let's talk about the HAL_Delay() function, which is commonly used when developing STM32 firmware.
Let's say we're writing code to make an LED blink every second.
while (1)
{
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12);
HAL_Delay(1000);
}This is simple and intuitive code.
But what if we add button input checks or sensor data processing?
While HAL_Delay(1000) is running, the current code flow pauses for about one second.
To be precise, the entire MCU does not stop, and interrupts can continue running. However, other tasks that need to be performed in the main loop are delayed by that amount.
So, is there a way to blink the LED while handling other tasks?
Another option is to use HAL_GetTick() as follows.
uint32_t previous = HAL_GetTick();
while (1)
{
if ((uint32_t)(HAL_GetTick() - previous) >= 1000U)
{
previous = HAL_GetTick();
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12);
}
// 다른 작업 수행
}With this approach, you can perform other tasks between LED updates.
Of course, this doesn’t mean HAL_Delay() is a bad function. It’s perfectly useful for simple waits or initialization. What matters is understanding your program’s execution flow and choosing the right approach for the situation.
This Week’s Little Challenge!
Try adding button input while controlling an LED in two different ways.
Compare how the response speed changes when you press the button.
Thinking through these issues is also an important foundation for understanding concepts you’ll learn later, such as timers, interrupts, and RTOS.
Thank you.
Sincerely, the Coding Newbie Rescue Team




