rdkartono Member Licensed User Longtime User Jul 26, 2016 #1 I have 8 pins A7~A0 and 8 pins D7~D0. The signal is : if A7=high, ignore it. If A7=low, time to read all A7~A0 and D7~D0. So I tried using A7.Addlistener function, or addlooper function, but still not fast enough to get all readings. So is it possible I create an inline C function, that doing : while (true) { .... .... } My purpose is to get (much) faster A7 response.
I have 8 pins A7~A0 and 8 pins D7~D0. The signal is : if A7=high, ignore it. If A7=low, time to read all A7~A0 and D7~D0. So I tried using A7.Addlistener function, or addlooper function, but still not fast enough to get all readings. So is it possible I create an inline C function, that doing : while (true) { .... .... } My purpose is to get (much) faster A7 response.
Erel B4X founder Staff member Licensed User Longtime User Jul 26, 2016 #2 Moving the loop to C will not make it faster. AddListener should be the fastest method (without using interrupts). Make sure that there isn't any other code that slows down the events. Upvote 0
Moving the loop to C will not make it faster. AddListener should be the fastest method (without using interrupts). Make sure that there isn't any other code that slows down the events.
rdkartono Member Licensed User Longtime User Jul 27, 2016 #3 This morning I did measurement with Oscilloscope, found out that A7 low pulse width is only 2 uS. And between A7 pulse to next pulse is 50uS interval. I guess interrupt approach is the best now, any suggestion ? Upvote 0
This morning I did measurement with Oscilloscope, found out that A7 low pulse width is only 2 uS. And between A7 pulse to next pulse is 50uS interval. I guess interrupt approach is the best now, any suggestion ?
Erel B4X founder Staff member Licensed User Longtime User Jul 27, 2016 #4 Running code from interrupts is problematic. Currently B4R doesn't support pin interrupts. You can try to use PulseIn: https://www.arduino.cc/en/Reference/PulseIn https://www.b4x.com/android/forum/threads/ultrasonic-ranging-module-hc-sr04.65786/ Upvote 0
Running code from interrupts is problematic. Currently B4R doesn't support pin interrupts. You can try to use PulseIn: https://www.arduino.cc/en/Reference/PulseIn https://www.b4x.com/android/forum/threads/ultrasonic-ranging-module-hc-sr04.65786/