Skip to content

Commit 09e85b7

Browse files
deadprogramaykevl
authored andcommitted
machine/stm32f103xx: correct convertion for fractional timing of RTC as used in ticks() function
Signed-off-by: Ron Evans <[email protected]>
1 parent 622d0eb commit 09e85b7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/runtime/runtime_stm32f103xx.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ func ticks() timeUnit {
124124
// convert RTC counter from seconds to microseconds
125125
timerCounter := uint64(stm32.RTC.CNTH<<16|stm32.RTC.CNTL) * 1000 * 1000
126126

127-
// add the fractional part of current time using DIV registers
128-
timerCounter += (uint64(stm32.RTC.DIVH<<16|stm32.RTC.DIVL) / 1024 * 32 * 32) * 1000 * 1000
127+
// add the fractional part of current time using DIV register
128+
timerCounter += uint64(0x8000-stm32.RTC.DIVL) * 31
129129

130130
// change since last measurement
131131
offset := (timerCounter - timerLastCounter)

0 commit comments

Comments
 (0)