[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Wrong time.sleep if time < 17ms
From: |
Ian Molton |
Subject: |
Re: Wrong time.sleep if time < 17ms |
Date: |
Fri, 10 Sep 2021 17:57:19 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
This isnt a compiler specific problem, but you might want to try
disassembling the code and seeing whats different -
objdump -D is your friend :)
-Ian
On 15/08/2021 19:30, D.Umbricht wrote:
> 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.
>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: Wrong time.sleep if time < 17ms,
Ian Molton <=