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.
STM32L4xx PWM Combined Mode
Moderator: RoccoMarco
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32L4xx PWM Combined Mode
Hi,
I think you need a custom driver for this. You may reuse parts of the existing driver but it is not designed for such a scenario.
Giovanni
I think you need a custom driver for this. You may reuse parts of the existing driver but it is not designed for such a scenario.
Giovanni
Re: STM32L4xx PWM Combined Mode
Giovanni wrote:Hi,
I think you need a custom driver for this. You may reuse parts of the existing driver but it is not designed for such a scenario.
Giovanni
If he can modify the stm32L4xx low level driver in such a way that doesn't require upper level hal_pwm changes, wouldn't that be okay? You would just be adding to the configuration structure in lld some custom registers. Could that be included in ChibiOS? Having chained/linked timers is a useful feature .. Something similar is essentially done with stm32 can filters.
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32L4xx PWM Combined Mode
He can also change the high level if he wishes so, the Apache license is permissive.
Giovanni
Giovanni
Re: STM32L4xx PWM Combined Mode
Giovanni wrote:He can also change the high level if he wishes so, the Apache license is permissive.
Giovanni
I wss thinking more along the lines off getting it included in the official trunk.
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32L4xx PWM Combined Mode
Not likely, I am striving for stability more than completeness, this kind of changes are a nightmare for testing and support.
At most it could go in the community repository, which is unmaintained by definition.
Giovanni
At most it could go in the community repository, which is unmaintained by definition.
Giovanni