Need help with PI PICO...

Liste des GroupesRevenir à cs raspberry-pi 
Sujet : Need help with PI PICO...
De : tnp (at) *nospam* invalid.invalid (The Natural Philosopher)
Groupes : comp.sys.raspberry-pi
Date : 23. Mar 2024, 19:45:05
Autres entêtes
Organisation : A little, after lunch
Message-ID : <utn4f2$3p985$1@dont-email.me>
User-Agent : Mozilla Thunderbird
Ok, this is the one destined to be an oil level sensor and I have been working on getting a stable TCP/IP and Wi-Fi stack, which seems to have been achieved, as its talking reliably, albeit with delay, to my most remote Wi-Fi AP at a signal level  generally around -87dbM.
That is not, however the problem (although I thought it was). The problem seems to be that very very occasionally and as far as I can tell *completely randomly*, it fails to return from the function listed below. Cargo culted from the module manufacturers application notes
This is for the ultrasonic transducer module.
When it fails, all GPIO pins to and from the transducer module measure  LOW.
static float get_distance()
{
int i;
absolute_time_t start;
absolute_time_t end;
static int64_t us_delay;
gpio_put(ULTRASONIC_OUT,0);
sleep_us(2);
//set output pin high
gpio_put(ULTRASONIC_OUT,1);
sleep_us(10);
gpio_put(ULTRASONIC_OUT,0); //reset the input
// wait for echo pulse start
while(!gpio_get(ULTRASONIC_IN))
;
//read clock and store
start=get_absolute_time ();
//wait for echo pin to go low;
while(gpio_get(ULTRASONIC_IN))
;
end=get_absolute_time ();
//get clock difference
us_delay=absolute_time_diff_us(start,end);
//convert to float and return it as cm
return (((float)(us_delay))*0.034/2);
}
It would seem from the pin states that it gets permanently stuck in
while(!gpio_get(ULTRASONIC_IN))
;
Which as understand it is waiting for the module (HCSR04) to *start* to send a pulse.
Now obviously infinite loops with no termination condition under fault conditions are poor code, but I am leaving it there until I understand why the code is in fact hanging.
Someone online suggested that asynchronous interrupts may be the issue, but I cant see why or what interrupts to disable.
Can anyone cast any light on this one?
Or suggest a bug hunting methodology?
--
“The fundamental cause of the trouble in the modern world today is that the stupid are cocksure while the intelligent are full of doubt."
    - Bertrand Russell

Date Sujet#  Auteur
23 Mar 24 * Need help with PI PICO...35The Natural Philosopher
23 Mar 24 +* Re: Need help with PI PICO...30Ahem A Rivet's Shot
24 Mar 24 i`* Re: Need help with PI PICO...29The Natural Philosopher
24 Mar 24 i +* Re: Need help with PI PICO...27Ahem A Rivet's Shot
24 Mar 24 i i`* Re: Need help with PI PICO...26The Natural Philosopher
25 Mar 24 i i `* Re: Need help with PI PICO...25Pancho
25 Mar 24 i i  `* Re: Need help with PI PICO...24The Natural Philosopher
26 Mar 24 i i   +- Re: Need help with PI PICO...1The Natural Philosopher
26 Mar 24 i i   +* Re: Need help with PI PICO...6Ahem A Rivet's Shot
26 Mar 24 i i   i`* Re: Need help with PI PICO...5The Natural Philosopher
26 Mar 24 i i   i `* Re: Need help with PI PICO...4David Higton
27 Mar 24 i i   i  `* Re: Need help with PI PICO...3The Natural Philosopher
28 Mar 24 i i   i   `* Re: Need help with PI PICO...2Robert Riches
28 Mar 24 i i   i    `- Re: Need help with PI PICO...1The Natural Philosopher
26 Mar 24 i i   +* Re: Need help with PI PICO...12Pancho
27 Mar 24 i i   i`* Re: Need help with PI PICO...11The Natural Philosopher
27 Mar 24 i i   i +* Re: Need help with PI PICO...2David Higton
27 Mar 24 i i   i i`- Re: Need help with PI PICO...1The Natural Philosopher
29 Mar 24 i i   i `* Re: Need help with PI PICO...8Pancho
29 Mar 24 i i   i  +* Re: Need help with PI PICO...6The Natural Philosopher
29 Mar 24 i i   i  i+* Re: Need help with PI PICO...2Pancho
29 Mar 24 i i   i  ii`- Re: Need help with PI PICO...1The Natural Philosopher
30 Mar 24 i i   i  i`* Re: Need help with PI PICO...3The Natural Philosopher
30 Mar 24 i i   i  i `* Re: Need help with PI PICO...2Pancho
30 Mar 24 i i   i  i  `- Re: Need help with PI PICO...1The Natural Philosopher
29 Mar 24 i i   i  `- Re: Need help with PI PICO...1druck
28 Mar 24 i i   +* Re: Need help with PI PICO...2Björn Lundin
28 Mar 24 i i   i`- Re: Need help with PI PICO...1The Natural Philosopher
29 Mar 24 i i   `* Re: Need help with PI PICO...2Michael Schwingen
29 Mar 24 i i    `- Re: Need help with PI PICO...1The Natural Philosopher
24 Mar 24 i `- Re: Need help with PI PICO...1Michael Schwingen
24 Mar 24 `* Re: Need help with PI PICO...4Theo
24 Mar 24  `* Re: Need help with PI PICO...3The Natural Philosopher
24 Mar 24   +- Re: Need help with PI PICO...1Michael Schwingen
24 Mar 24   `- Re: Need help with PI PICO...1Theo

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal