runtime/samd51: set minimum sleep to 260us due to minimum delay in register synchronization
Signed-off-by: Ron Evans <ron@hybridgroup.com>
Этот коммит содержится в:
родитель
0a5601c3fc
коммит
ef1bfe359c
1 изменённых файлов: 11 добавлений и 11 удалений
|
@ -201,8 +201,8 @@ func initRTC() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func waitForSync() {
|
func waitForSync() {
|
||||||
// for sam.GCLK.STATUS.HasBits(sam.GCLK_STATUS_SYNCBUSY) {
|
for sam.RTC_MODE0.SYNCBUSY.HasBits(sam.RTC_MODE0_SYNCBUSY_COUNT) {
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// treat all ticks params coming from runtime as being in microseconds
|
// treat all ticks params coming from runtime as being in microseconds
|
||||||
|
@ -232,9 +232,7 @@ func sleepTicks(d timeUnit) {
|
||||||
|
|
||||||
// ticks returns number of microseconds since start.
|
// ticks returns number of microseconds since start.
|
||||||
func ticks() timeUnit {
|
func ticks() timeUnit {
|
||||||
// request read of count
|
waitForSync()
|
||||||
// sam.RTC_MODE0.READREQ.Set(sam.RTC_MODE0_READREQ_RREQ)
|
|
||||||
// waitForSync()
|
|
||||||
|
|
||||||
rtcCounter := (uint64(sam.RTC_MODE0.COUNT.Get()) * 305) / 10 // each counter tick == 30.5us
|
rtcCounter := (uint64(sam.RTC_MODE0.COUNT.Get()) * 305) / 10 // each counter tick == 30.5us
|
||||||
offset := (rtcCounter - timerLastCounter) // change since last measurement
|
offset := (rtcCounter - timerLastCounter) // change since last measurement
|
||||||
|
@ -246,19 +244,21 @@ func ticks() timeUnit {
|
||||||
// ticks are in microseconds
|
// ticks are in microseconds
|
||||||
func timerSleep(ticks uint32) {
|
func timerSleep(ticks uint32) {
|
||||||
timerWakeup = false
|
timerWakeup = false
|
||||||
if ticks < 30 {
|
if ticks < 260 {
|
||||||
// have to have at least one clock count
|
// due to delay waiting for the register value to sync, the minimum sleep value
|
||||||
ticks = 30
|
// for the SAMD51 is 260us.
|
||||||
|
// For related info for SAMD21, see:
|
||||||
|
// https://community.atmel.com/comment/2507091#comment-2507091
|
||||||
|
ticks = 260
|
||||||
}
|
}
|
||||||
|
|
||||||
// request read of count
|
// request read of count
|
||||||
// sam.RTC_MODE0.READREQ.Set(sam.RTC_MODE0_READREQ_RREQ)
|
waitForSync()
|
||||||
// waitForSync()
|
|
||||||
|
|
||||||
// set compare value
|
// set compare value
|
||||||
cnt := sam.RTC_MODE0.COUNT.Get()
|
cnt := sam.RTC_MODE0.COUNT.Get()
|
||||||
|
|
||||||
sam.RTC_MODE0.COMP0.Set(uint32(cnt) + (ticks * 10 / 305)) // each counter tick == 30.5us
|
sam.RTC_MODE0.COMP0.Set(uint32(cnt) + (ticks * 10 / 305)) // each counter tick == 30.5us
|
||||||
waitForSync()
|
|
||||||
|
|
||||||
// enable IRQ for CMP0 compare
|
// enable IRQ for CMP0 compare
|
||||||
sam.RTC_MODE0.INTENSET.SetBits(sam.RTC_MODE0_INTENSET_CMP0)
|
sam.RTC_MODE0.INTENSET.SetBits(sam.RTC_MODE0_INTENSET_CMP0)
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче