CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIN_B0 as output then read its status Inquiry

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chingB



Joined: 29 Dec 2003
Posts: 81

View user's profile Send private message

PIN_B0 as output then read its status Inquiry
PostPosted: Sat Apr 17, 2004 11:10 pm     Reply with quote

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
PostPosted: Sun Apr 18, 2004 2:11 am     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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