Tech & AIInside Embedded | PolezeroHow Your Code Actually Spins a Motor (STM32 Registers to BLDC)

How Your Code Actually Spins a Motor (STM32 Registers to BLDC)

Long-form15:03EducationPublished Oct 22, 2026, 6:18 AM · 14h ago
Views
4,338
+299 views/hour
Views / hour now
299
measured 4m ago
Peak views / hour
529
5h ago
First 24 hours
—
not tracked from upload
Engagement
2.6%
likes + comments / views
Likes
105
2.4% of views
Comments
8
0.18% of views
Est. ad revenue
$30–$69
lifetime, $7–16 RPM

Checked every 30 min while the video is this age · last check 4m ago · next in 25 min. YouTube itself updates public counts with a short delay.

Avg views / day
4.3K
since upload
vs channel median
0.3×
this video's views ÷ the channel's usual
Rank in channel
#8
of 23 tracked

Views over time

14 readings

Total views Views gained per hour

Description

#STM32 #EmbeddedSystems #BLDC #Microcontroller #MotorControl #Firmware #Electronics How does one line of C code end up spinning a motor? We follow a single register write on an STM32 all the way down: from the CPU, through the timer, the gate driver and the MOSFETs, to the current flowing in a BLDC motor's coils. We start by turning on an LED with STM32 HAL, open up HAL_GPIO_WritePin, and replace it with a direct write to the BSRR register. From there we cover memory-mapped I/O and the STM32F767 memory map, peripheral clocks in RCC, reading three Hall sensors through the GPIO IDR register, six-step commutation in a switch statement, center-aligned PWM from TIM1 at 20 kHz, complementary outputs, dead time and the MOE bit in BDTR, the gate driver and three-phase inverter, what the CPU and bus actually do with a store instruction, and finally closed-loop motor speed control with a PI controller. Every line of code in this video is real firmware running on an STM32F767 BLDC motor-control lab board. Chapters 00:00 One line of code, one spinning motor 00:24 Turning on an LED with STM32 HAL 00:56 Inside HAL_GPIO_WritePin: the BSRR register 01:34 Skipping HAL: writing the register directly 01:47 GPIOC is just an address (volatile pointer) 02:16 STM32 memory map and memory-mapped I/O 02:57 Enabling peripheral clocks (RCC) 03:27 How a BLDC motor turns 04:14 Reading Hall sensors: IDR and HallSum 05:49 Six-step commutation in code (CCR, CCER) 06:53 PWM and the timer: 20 kHz center-aligned 08:04 Complementary outputs, dead time and MOE 08:57 Gate driver and three-phase inverter 10:11 MOSFETs, gate driver choice and PCB layout 10:31 The full loop, start to finish 11:03 What happens inside the MCU when you write an address 12:02 Closed-loop speed control with a PI controller 12:53 Building a BLDC motor controller from scratch (course) 14:39 Wrap-up: how far one line goes
Tags
STM32STM32 tutorialBLDC motor controlBLDC motorembedded systemsembedded programmingSTM32 register programmingbare metal STM32memory mapped IOSTM32 GPIOSTM32 PWMSTM32 timercomplementary PWMdead timehall sensorsix step commutationthree phase invertergate driverMOSFETPI controllermotor speed controlSTM32F767embedded Cfirmwaremicrocontrollerhow microcontrollers workmotor controllerpower electronicsInside Embedded

Statistics from the YouTube Data API, tracked by FameX. Views per hour, revenue and comparisons are FameX estimates.