vincenthimpe Regular Member Joined: 14/10/2018 Location: United StatesPosts: 86
Posted: 07:21pm 09 May 2025
Two issues :
1) That function operates on pin numbers. Not gpio numbers. if i want to set GP0 to GP7 i need to make a complicated definition to skip pin3 and 8(ground) . Pin numbers, in my opinion, are BAD : they tie you to a specific board. if somebody make a different board with different pin allocation nothing works anymore. IO should always be referred by using the processors pin name, not the boards pin name. But that's just my opinion. What do i know ?
2) looking at the C code of the interpreter the pin operations are sequential. They do not change at the same time but one after another. It's essentially a loop that scans through the list. This makes the actual output glitchy. if you go from 0000 to 1111 you get 0001 0011 0111 on the pins before you hit 1111. it gets worse when you go from a random pattern to another random pattern. Every bit flip produces an intermediary state.
The same for reading the port. The port is being scanned bit by bit. If you are trying to sample parallel inputs you can get wrong states if the inputs change during the scan. Let's say you want to make a simple logic analyser: if the data changes during the scan you get false information by using the PORT function.
It is not a true parallel read/ write.
My GPIO library is a true parallel read and write since it accesses the SIO registers directly. The inputs are sampled and stored into the input register in one clock cycle.
the only exception is on the 2350 where the bottom 31 bits are synchronous with each other, and 31..47 requires another bus cycle. This is due to the AMBA bus in the processor being only 32 bit. No way around that. But that's fine. At least there are 32 bits that work in parallel.
Footnote added 2025-05-10 09:41 by vincenthimpe Edit. V6.x performs the IO differently. it looks like it is no longer sequential now.