Deterministic functions
Posted: Sun Dec 05, 2021 3:06 pm
I have a RPi Pico board which I am using to output a trigger when a certain message is sent out via the UART. The code is:
Using a scope, I can see that the pin is not turned on at the same time every time the code above runs. The difference is quite small - in order of tens of microseconds, but it's still large enough to make the system not work.
I looked up online what I can do to make the code more deterministic, and I found this link, which proposes stopping the garbage collector before a critical call. I also watched Writing fast and efficient MicroPython, but did not find a direct reference to determinism. Can you advice what can be done to achieve deterministic behavior of critical sections of code?
Code: Select all
uart.write(cmd)
trigger_pin.on() # This is the important trigger edge
response = uart.read(n)
trigger_pin.off()
I looked up online what I can do to make the code more deterministic, and I found this link, which proposes stopping the garbage collector before a critical call. I also watched Writing fast and efficient MicroPython, but did not find a direct reference to determinism. Can you advice what can be done to achieve deterministic behavior of critical sections of code?