Electronics - FreeRTOS - Scheduler, task and queue on STM32F3Discovery

When it comes to dividing the time to share tasks, a simple microcontroller sometimes needs a friend. This friend is called FreeRTOS and will help our dear STM32 to dispatch tasks as if each one was written for the CPU entirely. Let’s see this. Shopping list The Github for the current tutorial with full files and code: https://github.com/badprog/badprog-electronics-freertos-scheduler-task-and-queue-on-stm32f3discovery IDE: VSCode DevContainer extension Board: STM32F3Discovery LSM303DLHC accelerometer (U3, small black chip on the right, above the pins) Datasheet: https://www.st.com/resource/en/reference_manual/rm0316-stm32f303xbcde-stm32f303x68-stm32f328x8-stm32f358xc-stm32f398xe-advanced-armbased-mcus-stmicroelectronics.pdf Logic Analyzer for I2C and UART bus communication ...

June 10, 2026 · Mi-K

Electronics - FreeRTOS - Semaphore and mutex on STM32F3Discovery with I2C and UART

Tasks are great, queues as well. But as soon as several tasks want to use the same resource at the same time, things get messy fast. This tutorial introduces 2 synchronisation mechanisms that keep everything in order: The mutex and the binary semaphore. Let’s get started. Shopping list The Github for the current tutorial with full files and code: https://github.com/badprog/badprog-electronics-freertos-semaphore-and-mutex-on-stm32f3discovery-with-i2c-and-uart IDE: VSCode DevContainer extension Board: STM32F3Discovery LSM303DLHC accelerometer (U3, small black chip on the right, above the pins) Datasheet: https://www.st.com/resource/en/reference_manual/rm0316-stm32f303xbcde-stm32f303x68-stm32f328x8-stm32f358xc-stm32f398xe-advanced-armbased-mcus-stmicroelectronics.pdf Logic Analyzer for I2C and UART bus communication ...

June 10, 2026 · Mi-K

Electronics - FreeRTOS - SPI, I2C, UART with stack watermark and IWDG watchdog on STM32F3Discovery

Two sensors, two buses, six tasks, one watchdog. This tutorial makes a firmware production-ready: Strict periodic scheduling, stack size validation, and hardware-level crash recovery. Ready? Let’s go. Shopping list The Github for the current tutorial with full files and code: https://github.com/badprog/badprog-electronics-freertos-spi-i2c-uart-with-stack-watermark-and-iwdg-watchdog-on-stm32f3discovery IDE: VSCode DevContainer extension Board: STM32F3Discovery LSM303DLHC accelerometer (U3, small black chip on the right, above the pins) L3GD20 3-axis MEMS gyroscope (U5, small chip near center) Datasheet: https://www.st.com/resource/en/reference_manual/rm0316-stm32f303xbcde-stm32f303x68-stm32f328x8-stm32f358xc-stm32f398xe-advanced-armbased-mcus-stmicroelectronics.pdf Logic Analyzer for I2C, SPI and UART bus communication ...

June 10, 2026 · Mi-K

Electronics - FreeRTOS - Timer, task notification and event group on STM32F3Discovery with I2C and UART

Mutexes protect, semaphores signal. But in some situations you need a bit more: A callback that fires on its own schedule, a direct line between an ISR and a task, and a way to say “do not start until everything is ready.” This tutorial introduces 3 FreeRTOS mechanisms that round out the toolkit: software timers, task notifications, and event groups. Let’s get started. Shopping list The Github for the current tutorial with full files and code: ...

June 10, 2026 · Mi-K

Electronics - STM32 - I2C communication between STM32F3Discovery and LSM303DLHC accelerometer

Every smartphone is nowadays provided with an accelerometer. In this tutorial we are going to see how to retrieve X, Y and Z values from the LSM303DLHC accelerometer on the STM32F3Discovery board. And to achieve this goal we’ll use I2C bus communication. Let’s get started. Shopping list The Github for the current tutorial with full files and code: https://github.com/badprog/badprog-electronics-stm32-i2c-communication-between-stm32f3discovery-and-lsm303dlhc-accelerometer IDE: VSCode DevContainer extension Board: STM32F3Discovery LSM303DLHC accelerometer (U3, small black chip on the right, above the pins) Datasheet: https://www.st.com/resource/en/reference_manual/rm0316-stm32f303xbcde-stm32f303x68-stm32f328x8-stm32f358xc-stm32f398xe-advanced-armbased-mcus-stmicroelectronics.pdf Logic Analyzer for I2C communication First things first The LSM303DLHC accelerometer sits on I2C1 register at address 0x19, connected to PB6 (SCL) and PB7 (SDA). ...

June 9, 2026 · Mi-K

Electronics - STM32 - Reading gyroscope data with SPI on STM32F3Discovery

So far we have blinked LEDs, rotated them with a timer, caught a button interrupt, and sent text over UART. Time to talk to an external chip. In this tutorial we are going to read angular velocity on X, Y, Z axes from the L3GD20 gyroscope soldered on the STM32F3Discovery board. We’ll use the SPI1 peripheral in bare metal C in order to decode a live transaction on a logic analyzer but also directly from the OpenOCD console. ...

June 5, 2026 · Mi-K

Electronics - STM32 - UART printf debugging with FTDI on STM32F3Discovery

At some point, blinking LEDs are not enough to understand what your code is actually doing. You need to print things. This tutorial shows how to redirect printf() to a serial port on the STM32F3Discovery with a FTDI TTL adapter. Shopping list The Github for the current tutorial with full files and code: https://github.com/badprog/badprog-electronics-stm32-uart-printf-debugging-with-ftdi-on-stm32f3discovery IDE: VSCode DevContainer extension Board: STM32F3Discovery Datasheet: https://www.st.com/resource/en/reference_manual/rm0316-stm32f303xbcde-stm32f303x68-stm32f328x8-stm32f358xc-stm32f398xe-advanced-armbased-mcus-stmicroelectronics.pdf Hardware for serial communication: FTDI TTL-232R-3V3 adapter (USB to TTL serial, 3.3V) Why use an FTDI cable? There are 3 ways to get serial output from the STM32F3Discovery: ...

June 4, 2026 · Mi-K

Electronics - STM32 - STM32F3Discovery LED ring rotation with TIM2 and NVIC

Our Christmas tree is almost ready. In our previous tutorial we saw how to blink all LEDs at the same time. The lights are blinking but Santa thinks it’s too static. Let’s make them rotate. Shopping list The previous tutorial for this series: electronics-stm32-blinking-all-f3discovery-leds-at-the-same-time The Github for the current tutorial with full files and code: https://github.com/badprog/badprog-electronics-stm32-stm32f3discovery-led-ring-rotation-with-tim2-and-nvic IDE: VSCode DevContainer extension Board: STM32F3Discovery Datasheet: https://www.st.com/resource/en/reference_manual/rm0316-stm32f303xbcde-stm32f303x68-stm32f328x8-stm32f358xc-stm32f398xe-advanced-armbased-mcus-stmicroelectronics.pdf What’s new compared to the previous tutorial In the previous tutorial we used a software delay delay_ms() to blink all 8 LEDs together. ...

June 3, 2026 · Mi-K

Electronics - STM32 - User button as EXTI with the STM32F3Discovery board

Santa is impressed by the rotating LEDs but now he wants to control them. Let’s add a push button with the EXTI (External Interrupt). Shopping list The previous tutorials for this series: electronics-stm32-blinking-all-f3discovery-leds-at-the-same-time electronics-stm32-stm32f3discovery-led-ring-rotation-with-tim2-and-nvic The Github for the current tutorial with full files and code: https://github.com/badprog/badprog-electronics-stm32-user-button-as-exti-with-the-stm32f3discovery-board IDE: VSCode DevContainer extension Board: STM32F3Discovery Datasheet: https://www.st.com/resource/en/reference_manual/rm0316-stm32f303xbcde-stm32f303x68-stm32f328x8-stm32f358xc-stm32f398xe-advanced-armbased-mcus-stmicroelectronics.pdf What this tutorial does Pressing the blue user button PA0 on the STM32F3Discovery toggles between two LED modes: ...

June 3, 2026 · Mi-K

Electronics - STM32 - Blinking all F3Discovery LEDs at the same time

Christmas is near (only 6 months), so we have to prepare our xmas tree. What a better option than using our dear STM32F3Discovery board as a Christmas lights? Let’s see this in this tutorial. (And yes, Santa Claus is watching you, so be kind.) Shopping list The Github for this tutorial with full files and code: https://github.com/badprog/badprog-electronics-stm32-blinking-all-f3discovery-leds-at-the-same-time IDE: VSCode DevContainer extension Board: STM32F3Discovery First of all With Ubuntu 24.04 trying to install gcc-arm-none-eabi compiler doesn’t work as expected. ...

June 2, 2026 · Mi-K