File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -205,11 +205,7 @@ func initRTC() {
205205
206206 // set Mode0 to 32-bit counter (mode 0) with prescaler 1 and GCLK2 is 32KHz/1
207207 sam .RTC_MODE0 .CTRL = sam .RegValue16 ((sam .RTC_MODE0_CTRL_MODE_COUNT32 << sam .RTC_MODE0_CTRL_MODE_Pos ) |
208- (sam .RTC_MODE0_CTRL_PRESCALER_DIV1 << sam .RTC_MODE0_CTRL_PRESCALER_Pos ) |
209- sam .RTC_MODE0_CTRL_MATCHCLR )
210- waitForSync ()
211-
212- sam .RTC_MODE0 .COMP0 = 0xffffffff
208+ (sam .RTC_MODE0_CTRL_PRESCALER_DIV1 << sam .RTC_MODE0_CTRL_PRESCALER_Pos ))
213209 waitForSync ()
214210
215211 // re-enable RTC
@@ -256,8 +252,8 @@ func ticks() timeUnit {
256252 sam .RTC_MODE0 .READREQ = sam .RTC_MODE0_READREQ_RREQ
257253 waitForSync ()
258254
259- rtcCounter := uint64 (sam .RTC_MODE0 .COUNT ) * 30 // each counter tick == 30.5us
260- offset := (rtcCounter - timerLastCounter ) // change since last measurement
255+ rtcCounter := ( uint64 (sam .RTC_MODE0 .COUNT ) * 305 ) / 10 // each counter tick == 30.5us
256+ offset := (rtcCounter - timerLastCounter ) // change since last measurement
261257 timerLastCounter = rtcCounter
262258 timestamp += timeUnit (offset ) // TODO: not precise
263259 return timestamp
@@ -277,7 +273,7 @@ func timerSleep(ticks uint32) {
277273
278274 // set compare value
279275 cnt := sam .RTC_MODE0 .COUNT
280- sam .RTC_MODE0 .COMP0 = sam .RegValue (uint32 (cnt ) + (ticks / 30 )) // each counter tick == 30.5us
276+ sam .RTC_MODE0 .COMP0 = sam .RegValue (uint32 (cnt ) + (ticks * 10 / 305 )) // each counter tick == 30.5us
281277 waitForSync ()
282278
283279 // enable IRQ for CMP0 compare
You can’t perform that action at this time.
0 commit comments