From 0a5601c3fc676f474e217cc52bd08d242dbb277f Mon Sep 17 00:00:00 2001 From: Ron Evans Date: Tue, 17 Sep 2019 19:26:52 +0200 Subject: [PATCH] runtime/samd21: set minimum sleep to 214us due to minimum delay in register synchronization Signed-off-by: Ron Evans --- src/runtime/runtime_atsamd21.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/runtime/runtime_atsamd21.go b/src/runtime/runtime_atsamd21.go index 50f53031..dbbf8f14 100644 --- a/src/runtime/runtime_atsamd21.go +++ b/src/runtime/runtime_atsamd21.go @@ -261,9 +261,12 @@ func ticks() timeUnit { // ticks are in microseconds func timerSleep(ticks uint32) { timerWakeup.Set(0) - if ticks < 30 { - // have to have at least one clock count - ticks = 30 + if ticks < 214 { + // due to around 183us delay waiting for the register value to sync, the minimum sleep value + // for the SAMD21 is 214us. + // For related info, see: + // https://community.atmel.com/comment/2507091#comment-2507091 + ticks = 214 } // request read of count