STM32L4xx PWM Combined Mode
Posted: Wed Oct 11, 2017 1:23 am
Hi,
I need to generate 5-6 PWM output (all synchronized with each other) with a STM32L476 and some of these PWMs are run time adjustable on their frequency, duty cycle and phase shift.
To achieve this, i need to utilize the master and slave timer mode (one timer to trigger start the other timer) and also the combined pwm output (combined two PWM output) to get the duty cycle and phase shift change done. For these i need to set some of the registers (CCMR1, CCMR2, SMCR, CR1) that not available in the hal_pwm_lld.h PWMConfig structure.
Currently, I'm modifying the PWMConfig structure for me to pass in those registers value and set them in pwm_lld_start(). Also put some flags to enable/disable the changes so it doesn't affect the legacy pwm lld hal.
I'm not sure if this the best way to do it, would like to hear your opinions. Thanks.
I need to generate 5-6 PWM output (all synchronized with each other) with a STM32L476 and some of these PWMs are run time adjustable on their frequency, duty cycle and phase shift.
To achieve this, i need to utilize the master and slave timer mode (one timer to trigger start the other timer) and also the combined pwm output (combined two PWM output) to get the duty cycle and phase shift change done. For these i need to set some of the registers (CCMR1, CCMR2, SMCR, CR1) that not available in the hal_pwm_lld.h PWMConfig structure.
Currently, I'm modifying the PWMConfig structure for me to pass in those registers value and set them in pwm_lld_start(). Also put some flags to enable/disable the changes so it doesn't affect the legacy pwm lld hal.
I'm not sure if this the best way to do it, would like to hear your opinions. Thanks.