[riot-notifications] [RIOT-OS/RIOT] cpu/stm32_common: fix rtt registers access (#11297)

Vincent Dupont notifications at github.com
Wed Mar 27 16:51:55 CET 2019

### Contribution description

According to stm32 manual ARR and CMP registers may have unpredictable results if ARROK and CMPOK flags are not checked:
The ARROK flag and the CMPOK flag in the LPTIM_ISR register indicate when the write
operation is completed to respectively the LPTIM_ARR register and the LPTIM_CMP
After a write to the LPTIM_ARR register or the LPTIM_CMP register, a new write operation
to the same register can only be performed when the previous write operation is completed.
Any successive write before respectively the ARROK flag or the CMPOK flag be set, will
lead to unpredictable results.

In the same vein, CNT register should be read twice to ensure the value is correct:
It should be noted that for a reliable LPTIM_CNT register read access, two consecutive read
accesses must be performed and compared. A read access can be considered reliable when the
values of the two consecutive read accesses are equal.

### Testing procedure

tests/periph_rtt is working. We had issues without this patch when plugging xtimer to use a rtt as timer.

You can view, comment on, or merge this pull request online at:


-- Commit Summary --

  * cpu/stm32_common: fix rtt registers access

-- File Changes --

    M cpu/stm32_common/periph/rtt.c (10)

-- Patch Links --


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190327/0c92a590/attachment.html>

More information about the notifications mailing list