Hi all
I try to move a go program from a raspberry pi to an arduino uno using
tinygo on the arduino.
The program works basically but there's one problem.
For the multiplexing of LED's I use the time.sleep function.
With time.sleep(17*time.Milliseconds) the delay is appr. 17ms.
However whenever the sleep time is < 17ms it actually the delay is only
appr. 50us.
I assume a problem in the time library but are not an expert.
$tinygo version
tinygo version 0.19.0 linux/amd64 (using go version go1.16.7 and LLVM
version 11.0.0)
I use the following test program:
package main
import (
"machine"
"time"
)
var gpio = []machine.Pin{
machine.ADC0,
machine.ADC1,
machine.D2,
machine.D3,
machine.D4,
machine.D5,
}
func main() {
// define gpio as output and set them LOW
for i := 0; i < len(gpio); i++ {
gpio[i].Configure(machine.PinConfig{Mode: machine.PinOutput})
gpio[i].Low()
}
for {
gpio[0].High() // pulse is app. 4us wide
gpio[0].Low()
gpio[1].High()
time.Sleep(time.Millisecond*50) // sleep time appr. 33.9ms
gpio[1].Low()
gpio[2].High()
time.Sleep(50*time.Microsecond) // sleep time appr. 52us
gpio[2].Low()
gpio[3].High()
time.Sleep(17*time.Millisecond) // sleep time appr. 17ms
gpio[3].Low()
gpio[4].High()
time.Sleep(16*time.Millisecond) // sleep time appr. 48us
gpio[4].Low()
} //end forloop
} //end
gcc version 5.4.0 (GCC)
avr-libc/focal,focal,now 1:2.0.0+Atmel3.6.1-2 all [installed]
Any help in this matter is very much appreciated.