Shop OBEX P1 Docs P2 Docs Learn Events
Lower I/O Pin Number=Faster Access Time? — Parallax Forums

Lower I/O Pin Number=Faster Access Time?

ercoerco Posts: 20,256
edited 2011-11-16 09:39 in BASIC Stamp
I just saw this statement at http://www.hobbyengineering.com/specs/devantech-srf04-tech.pdf

The new code is also useful when connecting the SRF04 to the slower Stamps such as the BS2. Although
the SRF04 works with the BS2, the echo line needs to be connected to the lower numbered input pins. This is
because the Stamps take progressively longer to look at the higher numbered pins and can miss the rising edge
of the echo signal. In this case you can connect the "do not connect" pin to ground and give it an extra 300uS to
get there.

Is it correct that lower number pins can operate faster? Never saw that mentioned anywhere else.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2011-11-16 06:51
    I don't know for sure, but I suspect that this depends on how you access the specific I/O pin. From a hardware standpoint, the I/O pins are implemented as two 8-bit I/O ports in the PIC. When you reference a single I/O pin using INn, the I/O port bit has to be shifted one bit at a time to produce the resulting 0 / 1 value. There would be a little more overhead to access the higher order 8 I/O pins, but then those would be shifted one at a time, so I/O pin 7 would be the slowest of the 0-7 group and I/O pin 15 would be the slowest of the 8-15 group. That's probably where the time difference comes from. It's not documented anywhere. There would be similar timing differences for I/O output.
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2011-11-16 08:22
    Access time for those BS2 instructions depends largely on how many bits have to be read out from the eeprom. So, it takes longer to read out an assignment to p15=%1111 than to read out p1=%1. Back up one step. The BS2 codes its instructions in a very efficient manner that does not respect byte boundaries. Each instruction is bit-coded and takes up only as many bits as it needs to represent the instruction and its data. So, the interpreter does in fact have to read out three more bits to retrieve %1111 than it does to retrieve %1. Once the bits are retrieved, the execution times are the same regardless of pin number. Take one step to the side. That said, the BS2 has a particularly efficient way of representing powers of 2. So 0, 1, 2, 4 and 8 are somewhat faster than they would be according to the above rule.
  • ercoerco Posts: 20,256
    edited 2011-11-16 09:00
    Excellent info guys, thanks. Just when I thought there was nothing left to learn on the BS2.

    What a great thread for my birthday week, with two of my three all-time favorite forum gurus sharing their top-notch tech knowledge. Once PhiPi weighs in, I can die happy. :)
  • PublisonPublison Posts: 12,366
    edited 2011-11-16 09:39
    Phil will just come up with a way to connect "do not connect" pin to plywood ground and have it run like a Propeller.

    I'm sure he's prototyping as we speak. :lol:
Sign In or Register to comment.