![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Guest
|
input_?() |
Posted: Wed Jul 12, 2006 7:08 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
|
Posted: Wed Jul 12, 2006 7:58 pm |
|
|
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!! |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jul 12, 2006 8:30 pm |
|
|
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);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Fri Jul 14, 2006 11:42 am |
|
|
Ok, thank you. I'll try with that. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|