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

port input without changing port direction

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







port input without changing port direction
PostPosted: Sun Aug 26, 2007 1:11 pm     Reply with quote

Is it possible to input an entire 8 bit port without changing the direction using the 16F series PICs? I have some pins on the port configured to output, and some to input.

i.e. same idea as input_state(PIN) , but input an entire port instead
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 26, 2007 1:27 pm     Reply with quote

There are two ways. You can temporarily enable "fast i/o" mode for
the input_b() operation, or you can declare the Port B address and read
the port directly. Both these methods produce the same ASM code in
the .LST file. They don't touch the TRISB register.
Code:

#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#byte PortB = 6

//=================================
main()
{
int8 c;

#use fast_io(B)
c = input_b();
#use standard_io(B)


c = PortB;

while(1);
}
Geoffry
Guest







Thanks
PostPosted: Sun Aug 26, 2007 9:32 pm     Reply with quote

Thanks so much! Exactly what I needed.
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