|
|
View previous topic :: View next topic |
Author |
Message |
chingB
Joined: 29 Dec 2003 Posts: 81
|
PIN_B0 as output then read its status Inquiry |
Posted: Sat Apr 17, 2004 11:10 pm |
|
|
Hello,
I would like to know if one pin is configured as output say PIN_B0 can be bit_test, to check if it is high or low?
What other algorithm could do this task?
Thnx |
|
|
Ttelmah Guest
|
Re: PIN_B0 as output then read its status Inquiry |
Posted: Sun Apr 18, 2004 2:11 am |
|
|
chingB wrote: | Hello,
I would like to know if one pin is configured as output say PIN_B0 can be bit_test, to check if it is high or low?
What other algorithm could do this task?
Thnx |
Yes.
There are a number of 'caveats'. The 'read', returns the real status of the pin. Now suppose the pin is driving a fairly capacitive load, and you have it set low, then send a command to set it high, and immediately read it to see what level it is at, the 'return' will still be low, snce it will take a significant number of microseconds for the pin to charge the capacitor to the new 'high' value. Now the particular problem here, is if you have other pins also in use on the port, and you read the status of the whole port, change a pin, and write the byte back (read-modify-write). If you did this, while the pin still had not charged to the 'high' level, the pin will be read as 'low', and will be written back as a low level!.
This problem is avoidable, on the latter chips (18Fxxx etc.), where the output 'latch' is also available to read/write. This is the register 'LATB', and a #byte declaration, allows this to be directly read/written. Otherwise, you just have to be careful to ensure that you do not read the port, until enough time has been allowed to pass for the reading on the pin to reflect the 'real' status.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|