boards/nucleo-f401: configure PWM on 7 pins#6192
Conversation
|
Hi As this seems to touch all STM32F[234] in some ways and not only nucleo-f4 the board I suggest indicating this in the PR subject. Support for F2 PWM is temporarily dropped and hopefully better support for F[34] PWM is added. This is an area where perhaps nonclamenture could be more exact. The STM32 family has several different PWM peripherals, none of which are specific to any particular Fx model, except possibly HRTIM, which seems to be available only in F334. Anyhow the STM32 timers are complex, their clock architecture elaborate and the whole issue around timing takes roughly quarter of the STM32 manual, so tackling this yak shaving in small pieces would make sense to me. ST doesn't help in not having a common to all STM32 reference manual but seems to treat the subfamilies as separate entities in the documentation when in reality they're built from the same modular blocks. I found a decent article about STM32 timers but even that forgets to mention F334 HRTIM completely :D All in all as the peripherals aren't model specific I'd rather see the timers supported as peripherals and then the support matrix (which timers in which models of mcu) as separate entities. This would in my view reflect the architecture of RIOT that a spefic board has a specific mcu that consists of a specific core and specific peripherals. Thus I suggest naming these peripherals stm32-gptimer stm32-basictimer stm32-advancedtimer stm32-hrtimer and then possibly have or not have similar naming scheme for the clocks and their interconnects available in the whole STM32 family. (this area needs better thinking than my fast off the cuff suggestion) Anyway the STM32 family is pretty modular so it is completely not necessary to see the models as separate from each other as the whole family shares possibility of having pretty much any STM32 peripheral available. Not all have but new models are prone to have any combination. This modularity is present especially if you're having a custom chip made for you as you could select for example Cortex M0 core, MAC and HRTIM only and nothing else (well really just about any combination, they all share the interconnect mechanisms). I'm hoping that in some not too far future those guys having chips made for products would be willing to look at RIOT... :)
|
|
@temmihoo. Thanks for commenting.
As said in the PR description (which is minimal), this PR is based on #6186 where most of the job is done. This PR only adds PWM definitions for the nucleo-f401 board on top of #6186. |
|
@aabadie Thx for notifying, I commented more or less the same in parent PR, including the link given. |
| * @{ | ||
| */ | ||
| static const pwm_conf_t pwm_config[] = { | ||
| { /* D3 */ |
There was a problem hiding this comment.
I would prefer not to use TIM2 for PWM, as the same timer is already mapped to the timer_ interface. If really wanted/needed for PWM, we should change the default TIMER_DEV(0) to TIM5 above in the timer configuration.
| .dev = TIM3, | ||
| .rcc_mask = RCC_APB1ENR_TIM3EN, | ||
| .pins = { GPIO_PIN(PORT_B, 4) }, | ||
| .af = GPIO_AF2, |
There was a problem hiding this comment.
with this configuration, TIM3 is overloaded -> this would lead to trouble. I think what you actually want is to configure TIM3 with 2 channels:
...
{ /* D5 and D9 */
.dev = TIM3,
.rcc_mask = RCC_APB1ENR_TIM3EN,
.pins = { GPIO_PIN(PORT_B, 4), GPIO_PIN(PORT_C, 7), GPIO_UNDEF, GPIO_UNDEF },
.af = GPIO_AF2,
.chan = 2,
.bus = APB1
},
...Note also, that you always need to map 4 pins, but you may set them to GPIO_UNDEF for un-used channels.
1f6cc71 to
2619a9d
Compare
|
@haukepetersen, thanks for reviewing. I was confused with the PWM configuration and could fix the issue thanks to your comments. I also had to remove |
c23f530 to
c0947c4
Compare
|
@haukepetersen, added the |
|
ping @haukepetersen |
8b93bbd to
aacaf10
Compare
|
@haukepetersen, rebased and adapted following changes from#6393. |
| .dev = TIM3, | ||
| .rcc_mask = RCC_APB1ENR_TIM3EN, | ||
| .chan = { { .pin = GPIO_PIN(PORT_B, 4) /* D5 */, .cc_chan = 0 }, | ||
| { .pin = GPIO_PIN(PORT_C, 7) /* D9 */, .cc_chan = 1 }, |
There was a problem hiding this comment.
channel setting seems wrong
aacaf10 to
8217ed1
Compare
|
All green, merging |
This PR is based on #6186.