SetPin GPnn, DOUT [DIN] setup time query


Author Message
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 04:25am 06 Sep 2023      

Hopefully somebody can help me on the right path :) please.

I'm trying to use the web server functionality of the Webmite but finding it quite unstable, i.e. the Pico is locking up. The HW Watchdog is too fast for some of the web server responses, as Peter has pointed out, and the software watchdog comes with its own challenges.

I believe the culprit to be the web server, as evidenced by an error message relating to a connection, when there shouldn't be, unless the web server is being overloaded by page requests. To overcome this apparent unanswered web request I have introduced a WEB TCP CLOSE a% in a For Loop with an ON ERROR SKIP at the exit of the web server interrupt sub routine, in the hopes of closing any lingering TCP Clients. This has not improved the web server stability.

To overcome this I have assembled a 555 astable multivibrator with a negative pulse when it times out. Time out is adjustable between ±0.5s and 80s. The low pulse is ±15ms.

At the console the commands below work as expected. The 555 reset output pulse is inhibited with the 555 being reset by the DOUT and when DIN the Hi-Z of the pin floats the reset input of the 555 and the timer counts.


> setpin gp14, din
> setpin gp14,dout
>


However I don't seem to be able to replicate this in the program itself. I have tried various combinations but either get errors relating to the pin's IO declaration or in the example below, no 555 reset and thus it times out and fires the low output pulse. The only way I can get any stability is to introduce a Pause 30 as indicated in the code below.


Sub PatDog
'SetPin GP14, DIN
SetPin GP14, DOUT 'Set pin to DOUT, should be low
'Pause 1000
'Port(GP14,1)=&H1
Pause 30
'Port(GP14,1)=&H0
SetPin GP14, DIN 'Set pin back to Hi-Z
End Sub


As an alternative I tried putting the SetPin GP14, DOUT in a for loop with 75 iterations, which appears to have a similar result.

This begs the question, how long does it take the Pico (MMBasic) to change the Pin's state from DIN to DOUT and for it to settle to a defined state? Or what am I missing that works at the console but not in the code?

If HW Watchdog is too short at 8331ms and Watchdog is not entirely reliable then what else is there to do?