File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 48
48
*/
49
49
uint32_t GetCurrentMicro (void )
50
50
{
51
- uint32_t m0 = HAL_GetTick ();
52
- uint32_t u0 = SysTick -> LOAD - SysTick -> VAL ;
53
- uint32_t m1 = HAL_GetTick ();
54
- uint32_t u1 = SysTick -> LOAD - SysTick -> VAL ;
55
-
56
- if (m1 > m0 ) {
57
- return ( m1 * 1000 + (u1 * 1000 ) / SysTick -> LOAD );
58
- } else {
59
- return ( m0 * 1000 + (u0 * 1000 ) / SysTick -> LOAD );
51
+ /* Ensure COUNTFLAG is reset by reading SysTick control and status register */
52
+ LL_SYSTICK_IsActiveCounterFlag ();
53
+ uint32_t m = HAL_GetTick ();
54
+ uint32_t u = SysTick -> LOAD - SysTick -> VAL ;
55
+ if (LL_SYSTICK_IsActiveCounterFlag ()) {
56
+ m = HAL_GetTick ();
57
+ u = SysTick -> LOAD - SysTick -> VAL ;
60
58
}
59
+ return ( m * 1000 + (u * 1000 ) / SysTick -> LOAD );
61
60
}
62
61
63
62
/**
You can’t perform that action at this time.
0 commit comments