2018-02-28 12:08 AM
Hi, I'm designing a low power application using a L452RE. In order to keep the power consumption to the minimum I turn ON and OFF the peripheral clocks only when I need to use the peripheral. My question is what happens to the peripheral registers when its clock is turned OFF ? Are they reset to their defaults values ? I would say no, but I want a confirmation here.
Second question is about the typical use of the RCC->AHBRSTR: when would someone reset a peripheral ?
Many thanks,
Kraal
#peripheral-clock #peripheral-reset2018-02-28 02:25 AM
when would someone reset a peripheral ?
When you want it restored to its reset state!
eg, if you wanted to re-configure it, and be sure that you were starting from a known state ...
2018-02-28 02:33 AM
If the datasheet / ref.manual doesn't tell you, test it yourself.
I have no personal experience with the L4xx family, which, IMHO, seems not as mature as other families like the F0, F1, F3 and F4.
But even if they retain their states, I would not rely on it.
2018-02-28 03:08 AM
Thank you for the answers.
I will reset them every time then...
2018-02-28 03:35 AM
Also not used
L4xx family as such but, generally, there are STM32 low-power modes which stop the CPU clock - and, thus, the peripheral clocks - and say that peripheral states are retained.
Perhaps you can find some examples and see what they do ...
2018-02-28 04:36 AM
Kraal wrote:
I will reset them every time then...
So you just answered your question of why anyone would want to reset a peripheral!
:)
2018-02-28 06:57 AM
Yes, these are fully-static designs, so I'd expect everything to be retained absent a clock.
Where one might get into trouble is with registers/counters which are invisible, where they restart is not going to be predictable/controllable. For instance prescale counters, baud rate dividers, input/output shift-registers, etc.