Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F4 timers not clocked at init #39

Closed
ag88 opened this issue May 8, 2020 · 2 comments
Closed

F4 timers not clocked at init #39

ag88 opened this issue May 8, 2020 · 2 comments

Comments

@ag88
Copy link

ag88 commented May 8, 2020

hi while messing with the timers on F4. i found it strange that the timers registers did not retain their values. on tracing the codes in debug.
i found that timers are not initialized.
it turns out there is a return statement right at the beginning of the timers initialization.
https://github.com/stevstrong/Arduino_STM32/blob/master/STM32F4/cores/maple/boards.cpp#L125
any reasons for this codes, effectively by passing initialization?

in addition, i'd think we can leave the timers in the disabled state after they are initialized.
and let user codes start the timers if they need them. e.g. commenting or removing the timer.resume()
https://github.com/stevstrong/Arduino_STM32/blob/master/STM32F4/cores/maple/boards.cpp#L155

@ag88 ag88 changed the title timers not clocked at init F4 timers not clocked at init May 8, 2020
@stevstrong
Copy link
Owner

I had an application in which I had headache figuring out why it did not work.
The reason was line 134 which sets the prescaler. That is why I decided to disable the whole timer initialization part.
In user applications the timer should anyway be paused, configured and resumed. One more line to initialize it at the beginning must be added in the future.

@ag88
Copy link
Author

ag88 commented May 8, 2020

i'm thinking for timer initialization at reset, it is adequate to simply clock the timers and pause() (disable) the timer. my guess is that this should reduce power consumption somewhat since the timers are not running.

i'm also thinking if we should try to be 'helpful' (e.g. setting TIMER_CR1_ARPE) or that we'd just leave it at the reset state but just disable the timers. i.e. TimerX.pause()

The initialization configuration are useful but that it should probably be done in user codes since we'd not know ahead the application scenario that is relevant. i'd think timers probably can have more support functions in the library e.g. output control, the thing is sometimes timers are just used to run other peripherals and the user may not want output to go on the pins. But we can work those additional functions as we go along.

i'm also thinking we'd clock the common timers e.g. TIM1, TIM2-5 and leave others unclocked. this could help save some power. and the availability of other timers tend to differ across socs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants