I was going through the handy step-by-step PIO guide by Volhout. The example code below was not behaving as expected. The pulsing on gp0 should stop when gp2 is low, but the pulsing did not start when gp2 was set hi. gp2 was always being read as low. The cure was to move the 'setpin gp2,dout' to the start of the program. The RP2350 has something called 'pad isolation latches', which the RP2040 does not have. The PIO initialization does not work correctly unless the pad isolation is disabled first (accomplished by the setpin dout). I'm no expert with PIO, so my explanation may be a bit off. Using PiPicoBT. 'disconnect ARM from GP0 setpin gp0,pio1
'configure pio1 p=Pio(pinctrl 0,1,,,,gp0,) f=1000 * 6 'Hz
'line code comment ' 0 � � E081 SET GP0 output ' 1 � � 2082 WAIT GP2=1 ' 2 � � E201 � �SET gp0 high, dly=2 ' 3 � � E000 � �SET gp0 low ' 4 � � 0001 � �JMP to 1
'program pio1 pio program line 1,0,&hE081 pio program line 1,1,&h2082 pio program line 1,2,&hE201 pio program line 1,3,&hE000 pio program line 1,4,&h0001
'write the configuration PIO init machine 1,0,f,p,,,0
'start the pio1 code PIO start 1,0
'toggle GP2 in MMBasic Setpin gp2,dout '---------------<<<<<-----move this to program start
do �pin(gp2) = 1 - pin(gp2) 'toggle pin GP2 �pause 100 loop |