|
Forum Index : Microcontroller and PC projects : Unintended GPIO output during start of program
| Author | Message | ||||
| Arne Regular Member Joined: 05/01/2025 Location: GermanyPosts: 46 |
Is there an easy possibility to block the output of data to the GPIOs before/during setting of GPIOs as outputs. My code is as follows: SetPin 24,dout SetPin 25,dout SetPin 26,dout SetPin 27,dout SetPin 29,dout SetPin 31,dout SetPin 32,dout SetPin 34,dout SetPin 11,dout SetPin 12,dout SetPin 14,dout SetPin 15,dout SetPin 16,dout SetPin 17,dout SetPin 19,dout SetPin 20,dout Port(11,2,14,4,19,2,24,4,29,1,31,2,34,1)=&B1111111111111111 If I start the program for approx. 5ms (during the SetPin - phase) unintended outputs to the GPIOs happen. A flickering of < 1 ms would be ok. Any ideas ? Arne |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10868 |
The pins will be high-Z when the program starts. If important you would need pullup or pulldown resistors on your board |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2940 |
> pin(1)=1 :setpin 1,dout :? pin(1):pin(2)=1 :setpin 2,dout :? pin(2) 1 1 > So you could try:- Pin(24)=1 : SetPin 24,dout Pin(25)=1 : SetPin 25,dout Pin(26)=1 : SetPin 26,dout Pin(27)=1 : SetPin 27,dout Pin(29)=1 : SetPin 29,dout Pin(31)=1 : SetPin 31,dout Pin(32)=1 : SetPin 32,dout Pin(34)=1 : SetPin 34,dout Pin(11)=1 : SetPin 11,dout Pin(12)=1 : SetPin 12,dout Pin(14)=1 : SetPin 14,dout Pin(15)=1 : SetPin 15,dout Pin(16)=1 : SetPin 16,dout Pin(17)=1 : SetPin 17,dout Pin(19)=1 : SetPin 19,dout Pin(20)=1 : SetPin 20,dout Port(11,2,14,4,19,2,24,4,29,1,31,2,34,1)=&B1111111111111111 It should make them go straight from high-Z to 1 without first being set to 0 (the default after Setpin) before the port command. Edited 2026-01-18 21:33 by phil99 |
||||
| Arne Regular Member Joined: 05/01/2025 Location: GermanyPosts: 46 |
To set the pins before SetPin command worked perfect. Thanks all, Arne |
||||
| DaveJacko Regular Member Joined: 25/07/2019 Location: United KingdomPosts: 92 |
While we're on the subject of GPIO.. can anyone point out what stupid mistake I'm making here? wire together GP0 and GP1 setpin GP0,dout setpin GP1,din pin (GP0)=1 print pin(GP1) - prints a 0 !! also tried pin(GP0)=0, and PWM 1Khz 50% checked with a meter, volts/freq as expected. Just getting 0 on GP1 (I'm ultimately trying to get a settick type interrupt > 1 KHz ) Thanks in anticipation mates. Try swapping 2 and 3 over |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2940 |
> setpin GP0,dout : setpin GP1,din > pin(GP0)=1 : ? pin(GP1) 1 > Check with a meter that you are getting 3.3V on GP1 at the pad on the Pico module. If so you may have a dead pin. Try GP2 etc. |
||||
| DaveJacko Regular Member Joined: 25/07/2019 Location: United KingdomPosts: 92 |
Thanks, Phil, I've tried that bit of code verbatim right now.. mine returns a zero yes, I previously checked with meter, 3+ volts tried another pico zero, same. I think I may be making an even more fundamentally stupid mistake, I'll sleep on it with a glass of Aussie red, will let you know how I get on Try swapping 2 and 3 over |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4209 |
You have a space after pin in pin (GP0)=1 Please try it without the space (sorry, I'm guessing it matters here but may be wrong). John |
||||
| DaveJacko Regular Member Joined: 25/07/2019 Location: United KingdomPosts: 92 |
thanks, John, but well spotted! tried it, don't think that's the problem.. sleeping on it Try swapping 2 and 3 over |
||||
| phil99 Guru Joined: 11/02/2018 Location: AustraliaPosts: 2940 |
I would have expected that to be the issue too, had I noticed it. A CODE window makes spaces clearer. However :- > pin(GP0)=0 : ? pin(GP1) Did not expect that! 0 > pin (GP0)=1 : ? pin(GP1) '1 space 1 > pin (GP0)=0 : ? pin(GP1) '1 space 0 > pin (GP0)=1 : ? pin(GP1) '2 spaces 1 > |
||||
TassyJim![]() Guru Joined: 07/08/2011 Location: AustraliaPosts: 6433 |
It should work as presented. As Phil suggested, try GP2 etc To see if one of the pins is reserved for some system purpose, try new option list list pins Jim VK7JH MMedit |
||||
| mozzie Senior Member Joined: 15/06/2020 Location: AustraliaPosts: 196 |
G'day DaveJacko, It might be a good idea to post the version of PicoMite and options list you are using, it could be a problem with a specific variant or option rather than generic. I have tried your code on a RP2350A and RP2040 using V6.02.00RC7 and both work as expected, something strange going on somewhere. What happens if you apply 3v3 direct to GP1? Regards, Lyle EDIT: Also tested on RP2040-Zero with V6.02.00RC7 and it works as expected. Possibly an option setting conflict? Edited 2026-01-19 12:45 by mozzie |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2026 |