Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:00 19 Feb 2026 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Unintended GPIO output during start of program

Author Message
Arne
Regular Member

Joined: 05/01/2025
Location: Germany
Posts: 48
Posted: 10:48am 18 Jan 2026
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10965
Posted: 11:06am 18 Jan 2026
Copy link to clipboard 
Print this post

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: Australia
Posts: 3016
Posted: 11:23am 18 Jan 2026
Copy link to clipboard 
Print this post

> 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: Germany
Posts: 48
Posted: 12:22pm 18 Jan 2026
Copy link to clipboard 
Print this post

To set the pins before SetPin command worked perfect.

Thanks all,

Arne
 
DaveJacko
Regular Member

Joined: 25/07/2019
Location: United Kingdom
Posts: 96
Posted: 09:26pm 18 Jan 2026
Copy link to clipboard 
Print this post

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: Australia
Posts: 3016
Posted: 10:24pm 18 Jan 2026
Copy link to clipboard 
Print this post

> 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 Kingdom
Posts: 96
Posted: 10:54pm 18 Jan 2026
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 4244
Posted: 11:12pm 18 Jan 2026
Copy link to clipboard 
Print this post

  DaveJacko said  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.

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 Kingdom
Posts: 96
Posted: 11:25pm 18 Jan 2026
Copy link to clipboard 
Print this post

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: Australia
Posts: 3016
Posted: 11:31pm 18 Jan 2026
Copy link to clipboard 
Print this post

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)
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
>
Did not expect that!
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6455
Posted: 11:52pm 18 Jan 2026
Copy link to clipboard 
Print this post

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: Australia
Posts: 204
Posted: 02:12am 19 Jan 2026
Copy link to clipboard 
Print this post

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
 
DaveJacko
Regular Member

Joined: 25/07/2019
Location: United Kingdom
Posts: 96
Posted: 10:12pm 19 Jan 2026
Copy link to clipboard 
Print this post

I went back in my shed to experiment further..

(objective; simply to link two pins, one with a pwm output >1000 Hz, the other to trigger an interrupt, >1000 Hz)

using gp0 as PWM out and gp1 as interrupt in, just returns constant gp1=0

other way round, gp0 as int and gp1 as pwm produces interrupts as expected!

Just to experiment further, tried random pins GP10,GP11
linked together,
GP10 won't drive GP11, and GP11 won't drive GP10, just get pin()=0
despite meter showing 0v/3v3 levels,
at 1 Hz in case you were wondering
on RP2040 Pico Zero running V6.00

aaargh!.. surely something that's my fault  
Try swapping 2 and 3 over
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 3016
Posted: 10:50pm 19 Jan 2026
Copy link to clipboard 
Print this post

Jim made an important suggestion earlier.
  Quote  To see if one of the pins is reserved for some system purpose, try
new (deletes the current program)
option list
list pins

If that doesn't reveal anything save the contents of A: and the current program then apply Clear_flash.uf2. That should restore it to Factory Fresh.
Then when you install new firmware it won't be compromised by the remains of the previous one.
 
DaveJacko
Regular Member

Joined: 25/07/2019
Location: United Kingdom
Posts: 96
Posted: 10:23pm 20 Jan 2026
Copy link to clipboard 
Print this post

I'm putting my perceived GPIO problem on the back-burner for now
(I'll try the clear_flash.uf2 nuke in due course, thanks Phil and all for your help)
I'm sure it will ultimately be my fault.

Having read the excellent manual carefully, using a hardware int to give a steady clock is unlikely to work, hardware ints are only serviced after completion of commands, so can be missed.

Thought of a new approach. I forgot that 'TIMER' counts in microseconds,
(assumed milliSecs)
so something like this might give a steady loop time

mainloop:
timer=0
<do your stuff>
waitloop:
if timer<0.1 then goto waitloop 'ie 10 kHz
goto mainloop

That said, the new stepper commands for RP2350 really are marvellous !
Try swapping 2 and 3 over
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 8568
Posted: 07:43am 21 Jan 2026
Copy link to clipboard 
Print this post

If it's of any use, the Count input has a hardware interrupt rather than being software dependent.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
DaveJacko
Regular Member

Joined: 25/07/2019
Location: United Kingdom
Posts: 96
Posted: 09:07pm 21 Jan 2026
Copy link to clipboard 
Print this post

Thanks Mick, I'll try that with a count of 1  
Try swapping 2 and 3 over
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2026