ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Apr 12, 2005 4:35 pm |
|
|
| James Bolver wrote: | Does the output state reset every time or does it stay in memory ?
IE: If I set the trisc to half low and half high then make portc inputs then switch back to outputs are all low again? | Hard to tell, not all PICs are the same in this respect, even different ports on the same chip may be different. Again, study the manual, especially the schematics in the chapters on the I/O-ports. Some of the chips I studied have data latches on both the inputs and outputs so ports will remember the previous state even when switching from output to input and back again.
This is quiet tricky and has caused many people problems while some others make good use of it by combining an input and output on the same pin. I've seen sample code of a single pin RS-232 receiver/transmitter.
Also notice that the PIC18 and PIC16 are different here, the PIC16 has strange behaviour when using read/modify/write instructions (BSF, BCF, XORWF) on the TRIS register in combination with peripherals overriding the TRIS bits. To avoid these problems a latch register was introduced in the PIC18 series. |
|