STM32F405 TIM9 through TIM14

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Selrak
Posts: 8
Joined: Mon Mar 25, 2013 10:10 am

STM32F405 TIM9 through TIM14

Post by Selrak »

Hello all,

So I'm working on STM32F405, and using many timers (because I want to drive many LEDs on PWM). Thing is though, the config files for ChibiOS on STMF405 only mention 8 timers, and indeed there are no more than 8 PWM driver structures ... How then do I drive timers 9 through 14 ? Thanks a lot for your help !

Charles
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F405 TIM9 through TIM14

Post by Giovanni »

Hi,

Support for TIM9 has been added yesterday, more could be added except those timers sharing their ISR with other timers, that would create portability problems in the driver.

You could also initialize the timers manually, if you don't need callbacks it is pretty simple, just copy the code from the existing driver into your application (the new license allows this).

Giovanni
Selrak
Posts: 8
Joined: Mon Mar 25, 2013 10:10 am

Re: STM32F405 TIM9 through TIM14

Post by Selrak »

I suppose you're really out of luck on this one, I don't use TIM9, only TIM12, 13 and 14 (for optimized routing around the MCU). And you say these have ISR sharing issues ? I can't find that on the reference manual.
But yes, all I'm doing is driving LEDs in intensity through a regular PWM without callbacks, nothing I couldn't do by hand if I needed - or indeed by reusing your code under your license if it allows it. Same need, same context - why not use the same tools after all ?
So, I'd redefine PWM Drivers I guess, and number them 12, 13, and 14, then initialize them by hand (which the HAL does automatically for the other drivers), and then call their methods normally (beginning with start) ?

Charles

PS : And thanks for the quick reply, that's one more reason it's a pleasure to work with ChibiOS (by the way, do you pronounce it /'kɪbɪ/ (as in Kobe) or /ˈtʃɪbɪ/ (as in chime) ?)
efuentes
Posts: 35
Joined: Wed Jul 25, 2012 6:16 am

Re: STM32F405 TIM9 through TIM14

Post by efuentes »

If you look at the interrupt table in the "Interrupts and Events" section of the reference manual, vectors 43,44 and 45 will fire for a specific event on timer 8 or for ANY reason on timers 12,13 and 14 respectively. This is specific to the STM32F4.

ChibiOS aims to provide a consistent software interface to the underlying hardware, which is tough because each product family has it's nuances. If support for timers 12,13 and 14 is to be added, it needs to be done in a way that it doesn't break compatibility with the other platforms.

As Giovanni mentioned, initializing and starting the timers happens in a way that is consistent with the currently supported timers. Callbacks are difficult because there is no clean way to handle shared interrupts across platforms.

Since it sounds like you just need to use PWM, you shouldn't need to worry about the shared interrupt not being supported.

Correct me if I've said anything wrong Giovanni!
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F405 TIM9 through TIM14

Post by Giovanni »

efuentes wrote:If you look at the interrupt table in the "Interrupts and Events" section of the reference manual, vectors 43,44 and 45 will fire for a specific event on timer 8 or for ANY reason on timers 12,13 and 14 respectively. This is specific to the STM32F4.

ChibiOS aims to provide a consistent software interface to the underlying hardware, which is tough because each product family has it's nuances. If support for timers 12,13 and 14 is to be added, it needs to be done in a way that it doesn't break compatibility with the other platforms.

As Giovanni mentioned, initializing and starting the timers happens in a way that is consistent with the currently supported timers. Callbacks are difficult because there is no clean way to handle shared interrupts across platforms.

Since it sounds like you just need to use PWM, you shouldn't need to worry about the shared interrupt not being supported.

Correct me if I've said anything wrong Giovanni!


I literally couldn't have explained it better :)

Probably I will create a ISR-less PWM mode and be done with it, this is a common request.

Giovanni
Selrak
Posts: 8
Joined: Mon Mar 25, 2013 10:10 am

Re: STM32F405 TIM9 through TIM14

Post by Selrak »

I totally understand your philosophy. And yes, if it is a common request, making an ISR-less mode for PWM drivers that have issues with that would be great - and that would totally preserve compatibility, wouldn't it ?

I'll take a look into the inner workings of the PWM drivers and try and copy whatever I need - and if you want, I can report on what to get rid of to create those new ISR-less drivers ? Although you're probably more fit for the task, as I am rather new to your OS ...
Selrak
Posts: 8
Joined: Mon Mar 25, 2013 10:10 am

Re: STM32F405 TIM9 through TIM14

Post by Selrak »

Working on TIM12, 13, and 14 PWM drivers without interrupts and all (only pin toggling on compare). I read and understood how it's done for TIM1 through 8, it's very portable given that the config registers are all at the same offset and have the same bitmap. Just need to redefine rccEnableTIM / rccResetTIM. Will set DIER of all timers to 0 (thus disabling NVICs).
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F405 TIM9 through TIM14

Post by Giovanni »

Yes, you just have the duplicate the few parts which are unit-specific and it will just work.

Giovanni
Selrak
Posts: 8
Joined: Mon Mar 25, 2013 10:10 am

Re: STM32F405 TIM9 through TIM14

Post by Selrak »

It worked real well, in fact. Once I got around 1. the underlying hardware functioning of the timers and 2. the way it is referred to in Chibi (with all the macros) I was able to easily duplicate all necessary parts. One thing remained mysterious, it was how to use and call nvicDisable, specifically how the macros used as arguments worked. So I just set the DIER hardware register to 0, effectively disabling interrupts (but loosing some generality and adaptability). But it works ! So it's possible - and not too hard, at that.
User avatar
alex31
Posts: 445
Joined: Fri May 25, 2012 10:23 am
Has thanked: 57 times
Been thanked: 88 times

Re: STM32F405 TIM9 through TIM14

Post by alex31 »

Giovanni wrote:Hi,

Support for TIM9 has been added yesterday, more could be added except those timers sharing their ISR with other timers, that would create portability problems in the driver.

Giovanni



Hi

Do you plan to add TIM9 on the ICU side too ?

I am blocking against the icu limitation, between not being able to use icu9 , and the fact that the channel are limited to 1 and 2,
it's becoming difficult for me to find a way to test my hardware setup.

for my now problem, if one of the two limitation goes away, it 'll save my day since i want, on an autopilot
to have a rc input pin which can accept s-bus data (futaba or specrum) or ppm.

i plan to use pin a3 which can be usart2rx or tim9 ch2, or tim5 ch4 (or tim2 ch4, but i already use the 4 channels of tim2 for pwm generation).
if any of the two limits goes out, i'll will use either tim9 or tim5 for icu.

Alexandre
Post Reply