David-OConnor / stm32-hal

This library provides access to STM32 peripherals in Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TIM1/TIM8 CC channels broken on STM32L476

badrbouslikhin opened this issue · comments

Hello,

  • When using TIM1, there's a panic when trying to enable PWM output on channel 3 or 4.
  • When using TIM8, there's a panic when trying to enable PWM output on anything but channel 1.

I believe this is related to this line and this line.

Is it the intended behavior?

Thanks!

I confirmed in the RM that L476 (as well as some other variants) have up to 6 channels on TIM1 and TIM8. The root of this is a PAC bug. Would need a YAML patch. Workaround in the mean while is probably to write to the relevant registers directly using an integer you calculate. Long term is getting the PAC fixed with an issue or PR here.

Of note, now that you brought this to my attention, I pushed a change allowing up to 4 channels on TIM8 on most STM32s. L4 and L5 excepted; they have more channels, but the PAC is missing them. PAC is bugged on TIM1 for many variants.

*Actually, got TIM8 to work with 2 channels on L476.

I was able to get TIM1 channels 3 and 4 working by naively applying the following changes: tim1_8_channels.zip
Do you see an issue with this (besides the fact that it's not a generic approach)?

What's the issue you're pointing to in the PAC? I'll be happy to spend some time fixing it upstream.

Good call; tested; will be in the next commit. The PAC issue is having to feature-gate cc4np. That's easy to work around in the PAC though. Nice find/fixes!

Released

Of note, it's not just the L4 PAC that has ommissions; several do, esp on TIM1!

Released

Of note, it's not just the L4 PAC that has ommissions; several do, esp on TIM1!

I'll give it a try this week-end!