Now you have taken the above tutorial lets start this tutorial. I am going to generate variable pwm signal on 1 Hz frequency that is generated in the previous tutorial. 1 Hz in time domain is equal to 1 second. I am going to output this variable signal on a led which is connected to output of stm32f103. Timer-4 channel-1 of stm32f103 is used to output variable pwm signal. Channel-1 corresponds to Prt-B Pin number 6 – PB-6 pin of stm32f103 microcontroller.
I am using this cheap $1.5 stm32f103c8t6 development board purchased from aliexpress. It does not have a programmer built on it. I am using an external stlink v2 programmer to program the module.
Circuit of the project is simple connect the anode(positive led) of led to pin PB-6 and ground the cathode(negative leg). No resistor is required since the stm32 works on 3.3 v and its gpio’s also source max 3.3 volt which is near the voltage required by a red color led.
__HAL_TIM_SetCompare(&htim4, TIM_CHANNEL_1, pwm);
Watch the Project Video Here…
Filed Under: Microcontroller Projects, STM32