I'm trying to connect two PIC 16f627 chips together (programmed with PICC-Lite) with one I/O pin (RA2, which changes direction at known points) and a CLK pin which is driven by one of the chips.
I originally had it set up so there was a master and a slave. The master would write an 8-bit 'command', the i/o pins' TRIS bits would be flipped and the slave would respond with a 16bit 'answer'.
I've put in (temporary, big) delays to ensure that there are no timing issues.
Writing/reading the command works fine, and both ends flip state (TRISA). However, at this point when the master is to read from a pin it's previously written to, it always reads 0 even if the pin is physically 1!
As far as I can tell, TRISA is set correctly (=set for bit if input), as is CMCON (=7), and I believe the CONFIG word; it is the same for both chips (well, inverted), and input works on the slave... I've also tried to make sure TRISA is never 0 for both chips simultaneously.
What I've tried: - Changing the slave so that instead of trying to send data back, it just toggles the value of it's output pin at long intervals. This can be seen on the output wire, but not on the value of the input pin. - Just passing the state through from the input pin to a different output pin (output remains zero; dummy placement showed that general output on that pin works) - Writing the values of PORTA and TRISA to an LCD - TRISA is correct but PORTA is 0 (even when the wire to the pin is high) - Hooking up the I/O line to an LED shows that it is changing, but the input value on the port is not - Hooking up a voltmeter shows a suitable voltage (equal to V+) - I tried swapping out the Master for a replacement (it figured it may have suffered some physical damage), though this made no difference - I've read that this could be a 'read-modify-write' issue, but I could find no advice for ensuring this is not the case on Pic16s... (there are no LAT ports AFAIK?)
I'm banging my head against the wall on this one. Any hints or ideas would be massively appreciated! I may have to fall back on using two pins (though I was kind of hoping I'd be able to drop in multiple slaves at some point with a single shared I/O line...)