JWood48
11/20/2022, 1:05 PMbmentink
11/20/2022, 7:42 PMprint
to the end, as it takes time ... my 2c 🙂JWood48
11/20/2022, 8:39 PMsmolesen
11/21/2022, 6:29 AMJWood48
11/21/2022, 7:53 AMfloitsch
11/21/2022, 10:19 AMfloitsch
11/21/2022, 10:20 AMfloitsch
11/21/2022, 10:22 AMwait_for
(as well as the print
...) might take some time to set up, and during that time edge transitions might be missed. However, once the wait_for
is correctly set up, then we should not miss any edge transition.
For example, if you have pulses that are once every millisecond, then it's not unlikely that you will miss some.
However, if there is one every second, then that's bad and we need to investigate.JWood48
11/22/2022, 9:18 AMJWood48
11/22/2022, 9:21 AMfloitsch
11/22/2022, 9:22 AMfloitsch
11/22/2022, 9:23 AMJWood48
11/22/2022, 9:34 AMfloitsch
11/22/2022, 9:35 AMfloitsch
11/22/2022, 9:37 AMJWood48
11/22/2022, 10:12 AMJWood48
11/22/2022, 10:13 AMfloitsch
11/22/2022, 10:14 AMJWood48
11/22/2022, 10:15 AMfloitsch
11/22/2022, 10:15 AMwait_for
, but apparently I made a mistake.floitsch
11/22/2022, 10:15 AMfloitsch
11/22/2022, 10:16 AMJWood48
11/22/2022, 10:18 AMfloitsch
11/22/2022, 10:20 AMfloitsch
11/22/2022, 10:20 AMJWood48
11/22/2022, 10:21 AMDETECTED: 103 at: 1064443 elapsed: 1600
DETECTED: 120 at: 1066043 elapsed: 1599
DETECTED: 162 at: 1067633 elapsed: 1590
DETECTED: 177 at: 1069223 elapsed: 1589
DETECTED: 188 at: 1070813 elapsed: 1590
DETECTED: 204 at: 1072413 elapsed: 1599
DETECTED: 220 at: 1074013 elapsed: 1600
floitsch
11/22/2022, 10:21 AMJWood48
11/22/2022, 10:21 AMJWood48
11/22/2022, 10:22 AMDETECTED: 0 at: 1104575 elapsed: 1608
DETECTED: 1 at: 1104576 elapsed: 1
DETECTED: 0 at: 1106184 elapsed: 1607
DETECTED: 1 at: 1106185 elapsed: 1
DETECTED: 0 at: 1114224 elapsed: 8038
DETECTED: 1 at: 1114226 elapsed: 1
DETECTED: 0 at: 1119034 elapsed: 4808
DETECTED: 1 at: 1119036 elapsed: 1
DETECTED: 0 at: 1128674 elapsed: 9638
DETECTED: 1 at: 1128675 elapsed: 1
DETECTED: 0 at: 1135114 elapsed: 6438
DETECTED: 1 at: 1135116 elapsed: 1
DETECTED: 0 at: 1138334 elapsed: 3218
floitsch
11/22/2022, 10:24 AMfloitsch
11/22/2022, 10:24 AMfloitsch
11/22/2022, 10:26 AMfloitsch
11/22/2022, 10:26 AMUnit
floitsch
11/22/2022, 10:26 AMglitch_filter_ns
.floitsch
11/22/2022, 10:46 AMfloitsch
11/22/2022, 10:48 AMfloitsch
11/22/2022, 10:49 AMwait_for
code looks at the current state of the pin when it wakes up from the interrupt, and ignores the wake-up if the pin value isn't what it expected.floitsch
11/22/2022, 10:50 AMfloitsch
11/22/2022, 10:51 AMJWood48
11/22/2022, 10:52 AMfloitsch
11/22/2022, 10:54 AMblink
function is run in an interrupt.floitsch
11/22/2022, 10:54 AMfloitsch
11/22/2022, 10:54 AMwait_for
is blocking your task, we have to schedule the event, so that the task gets woken up again.floitsch
11/22/2022, 10:55 AMfloitsch
11/22/2022, 10:55 AMfloitsch
11/22/2022, 10:55 AMfloitsch
11/22/2022, 10:57 AMfloitsch
11/22/2022, 10:57 AMprintf
in an interrupt function.floitsch
11/22/2022, 10:58 AMserial.print
is safe, though.floitsch
11/22/2022, 10:59 AMJWood48
11/22/2022, 11:03 AMfloitsch
11/22/2022, 11:04 AMfloitsch
11/22/2022, 11:05 AMfloitsch
11/22/2022, 11:05 AMJWood48
11/22/2022, 11:19 AMfloitsch
11/22/2022, 11:22 AMimport gpio
import rmt
main:
pin := gpio.Pin ...
channel := rmt.Channel pin --input --idle_threshold=32000 --no-enable_filter --memory_block_count=8
signals := channel.read
print signals
floitsch
11/22/2022, 11:23 AMfloitsch
11/22/2022, 11:24 AMfloitsch
11/22/2022, 11:27 AMfloitsch
11/22/2022, 11:27 AMfloitsch
11/22/2022, 11:28 AMfloitsch
11/22/2022, 11:29 AMfloitsch
11/22/2022, 11:29 AMfloitsch
11/22/2022, 11:30 AMfloitsch
11/22/2022, 11:30 AMJWood48
11/22/2022, 11:47 AMfloitsch
11/22/2022, 5:27 PMwait_for
. Hopefully it will be more stable with the new approach.
Will clean up my patch tomorrow and upload it for review.
It will hopefully be in the next release.JWood48
11/23/2022, 7:02 AMJWood48
11/23/2022, 7:03 AMREAD_CHANNEL...
SIGNALS: 0-2590 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-2 0-1 1-1 0-1 1-0
READ_CHANNEL...
SIGNALS: 0-2580 1-1 0-1 1-1 0-10 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-0
READ_CHANNEL...
SIGNALS: 0-2588 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-1 0-1 1-0
JWood48
11/23/2022, 7:04 AMfloitsch
11/23/2022, 7:45 AMwait_for
.
If I interpret this correctly it's relatively short though: 2.5ms
This is exactly what my patch should fix.kasperl
11/26/2022, 12:45 PMpin.wait_for
is part of Toit v2.0.0-alpha.42 that ships in Jaguar v1.7.9, which is released everywhere except on Windows where we are waiting a day or two for a code signing issue. Almost there 🙂kasperl
11/26/2022, 8:46 PMJWood48
11/26/2022, 10:15 PMfloitsch
11/26/2022, 10:15 PMJWood48
11/26/2022, 10:15 PMbmentink
11/27/2022, 1:02 AMjag flash
knows nothing about the --chip
argument ... cherrskasperl
11/27/2022, 7:00 AM