Page 1 of 1

[patch] add TIM12 and TIM14 support for STM32 TIMv1

Posted: Sat Jun 09, 2018 2:28 am
by tridge
The attached patch adds TIM12 and TIM14 support for STM32 TIMv1. TIM12 was tested on a STM32F765. TIM14 was tested on a STM32F427.
The patch is tested against stable_18.2.0. We also tested it against trunk, but on trunk we're getting some weird systick timing issues at the moment on a STM32F427, so we've backed off to 18.2.0 for testing.
Cheers, Tridge

Re: [patch] add TIM12 and TIM14 support for STM32 TIMv1

Posted: Sat Jun 09, 2018 6:31 am
by Giovanni
Hi,

This has been proposed already several times, some timers are not supported because sharing of interrupts, it would fail, for example, if you enable TIM1 for PWM and a sharing timer for ICU, GPT or ST. There would be two conflicting ISR.

The correct way to handle this is to disable the ISR in the various drivers and add it to hal_isr.c under the platform directory, this way it would be shared. The mechanism are already in place but it has not yet implemented. The problem is that you have to do that for ALL platforms, not just in the driver.

Second problem, all mcuconf.h files in all demos and test applications have to be updated when introducing new configuration options, registry files have to be updated for all platforms and the thing has to work for all platforms.

Giovanni

Re: [patch] add TIM12 and TIM14 support for STM32 TIMv1

Posted: Sat Jun 09, 2018 6:43 am
by Giovanni
Ah,

Just a note. I am added tools that re-align configuration files automatically, unfortunately it is not yet done for all kind of mcuconf.h files, probably it would be better to defer changes to configuration files to after the tool is available for all types.

Look under /chibios_trunk/tools/updater, I think it is interesting in itself.

The tool is not complex but it requires a new #define to be added to all files. When it is done, we need just to change the template (those .fmpp files) and the tool will re-align all instances to the new template.

Giovanni

Re: [patch] add TIM12 and TIM14 support for STM32 TIMv1

Posted: Sat Jun 09, 2018 9:10 am
by tridge
Giovanni wrote:The correct way to handle this is to disable the ISR in the various drivers and add it to hal_isr.c under the platform directory, this way it would be shared. The mechanism are already in place but it has not yet implemented. The problem is that you have to do that for ALL platforms, not just in the driver.

ahh, interesting!
So, now you have me worried that we may have an interrupt conflict on one of our boards without knowing it. We do use PWM, ICU, EICU and GPT. Which ones get used depends on both compile time and runtime options.
To check this I presume I need to know which vector each service is using, and check for conflicts. For example, TIM12 on all STM32F* boards where TIM12 exists is VectorEC, and that seems to be unique (ie. no other device uses that vector as far as I can see), so that one seems OK. TIM14_HANDLER is VectorF4 on everything except STM32F0, where it is Vector8C. That also seems unique.
It looks like these two are unique across all of STM32F*, is that correct? Or have I misunderstood the conflict?
When you say "all platforms", do you mean just STM32 for something like this, or do you mean other architectures?

Re: [patch] add TIM12 and TIM14 support for STM32 TIMv1

Posted: Sat Jun 09, 2018 10:13 am
by Giovanni
By platform I mean the various STM32 variants, all those you see under /os/hal/ports/STM32. I need to make sure changes consider all of them because drivers are shared.

It happens continuously that I apply an apparently innocuous change and then something breaks somewhere else, see the recent bug introduced on F1 because UART differences for example.

STM32 HAL is an complex beast because all dependencies.

Giovanni

Re: [patch] add TIM12 and TIM14 support for STM32 TIMv1

Posted: Sat Jan 05, 2019 1:08 pm
by Giovanni
Hi,

See here: viewtopic.php?f=3&t=4956

Probably now it is possible.

Giovanni