Difference between revisions of "STM32 bit bang PWM"

From Stm32World Wiki
Jump to navigation Jump to search
(Created page with "Category:STM32Category:STM32 DevelopmentCategory:STM32CubeMXCategory:STM32CubeIdeCategory:STM32 HAL{{metadesc|How to bitbang PWM}} On many of the cheaper [...")
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[Category:STM32]][[Category:STM32 Development]][[Category:STM32CubeMX]][[Category:STM32CubeIde]][[Category:STM32 HAL]]{{metadesc|How to bitbang PWM}}
 
[[Category:STM32]][[Category:STM32 Development]][[Category:STM32CubeMX]][[Category:STM32CubeIde]][[Category:STM32 HAL]]{{metadesc|How to bitbang PWM}}
On many of the cheaper [[STM32]] [[Development Board]]s.
+
On many of the cheaper [[STM32]] [[:Category:Development_Board|Development Boards]] there is a [[LED]] attached to PC13.  This is perfectly ok if you want to switch it on or off, but PC13 is not attached to any of the timer channels, so it will not be possible to control the brightness using [[PWM]].
 +
 
 +
Fortunately, while not ideal, it ''is'' possible to bitbang the [[PWM]] in a manner which doesn't require too much computation.  Contrary to [[PWM]] using a [[Timer]] channel, it does require some computation in the [[MCU]].
 +
 
 +
== Bit-banding ==
 +
 
 +
 
 +
== Result ==
 +
 
 +
{{#ev:youtube|rKyaacNsUPo}}
 +
 
 +
== Miscellaneous Links ==
 +
 
 +
* ]https://github.com/STM32World/firmware/tree/master/mcustm32f405_bitbang_pwm Stm32World STM32F405 Example]
 +
* [https://github.com/lbthomsen/blackpill/tree/master/bitbang_pwm Blackpill STM32F411 Example]

Revision as of 04:20, 6 May 2024

On many of the cheaper STM32 Development Boards there is a LED attached to PC13. This is perfectly ok if you want to switch it on or off, but PC13 is not attached to any of the timer channels, so it will not be possible to control the brightness using PWM.

Fortunately, while not ideal, it is possible to bitbang the PWM in a manner which doesn't require too much computation. Contrary to PWM using a Timer channel, it does require some computation in the MCU.

Bit-banding

Result

Miscellaneous Links