mirror of https://github.com/ARMmbed/mbed-os.git
STM32 LPTICKER : read counter
parent
8179d96d4d
commit
2b8d6cbcc5
|
@ -179,6 +179,11 @@ static void LPTIM1_IRQHandler(void)
|
||||||
uint32_t lp_ticker_read(void)
|
uint32_t lp_ticker_read(void)
|
||||||
{
|
{
|
||||||
uint32_t lp_time = LPTIM1->CNT;
|
uint32_t lp_time = LPTIM1->CNT;
|
||||||
|
/* Reading the LPTIM_CNT register may return unreliable values.
|
||||||
|
It is necessary to perform two consecutive read accesses and verify that the two returned values are identical */
|
||||||
|
while (lp_time != LPTIM1->CNT) {
|
||||||
|
lp_time = LPTIM1->CNT;
|
||||||
|
}
|
||||||
return lp_time;
|
return lp_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue