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 CCS Technical Support

input_?()

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








input_?()
PostPosted: Wed Jul 12, 2006 7:08 pm     Reply with quote

Hi,

Is posible to read 8 pins of different ports simultaneously?
for example, I know that using input_b() I can read 8 bits of portb, but is it posible pre-configure any of them ? may be using any #USE_?? or something in order to make a "virtual port" using pins from diferent ports ?.

Thank you.
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Jul 12, 2006 7:58 pm     Reply with quote

If you mean simultaneously as in one instruction. No. The underlying PIC does not support virtualization so there is no way the compiler can do it.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 12, 2006 8:30 pm     Reply with quote

Something like this would be about the best you can do.
Code:

#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

// Port addresses for 16F877.
#byte PortA = 5
#byte PortB = 6
#byte PortC = 7
#byte PortD = 8
#byte PortE = 9


// Read various pins on different ports,
// pack them into a byte, and return it.
int8 read_pins(void)
{
int8 retval;
#bit b0 = retval.0
#bit b1 = retval.1
#bit b2 = retval.2
#bit b3 = retval.3
#bit b4 = retval.4
#bit b5 = retval.5
#bit b6 = retval.6
#bit b7 = retval.7
   
b0 = bit_test(PortA, 0);
b1 = bit_test(PortA, 2);
b2 = bit_test(PortB, 1);
b3 = bit_test(PortB, 4);
b4 = bit_test(PortB, 5);
b5 = bit_test(PortC, 0);
b6 = bit_test(PortC, 1);
b7 = bit_test(PortC, 2);
   
return(retval);   
}   

//========================
void main()
{
int8 value;

value = read_pins();

while(1);
}
Guest








PostPosted: Fri Jul 14, 2006 11:42 am     Reply with quote

Ok, thank you. I'll try with that.
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