View previous topic :: View next topic |
Author |
Message |
ysaacb
Joined: 12 Jun 2006 Posts: 19
|
Accessing individual pins simultaneously ? |
Posted: Thu Oct 18, 2007 2:11 pm |
|
|
1.-How can I modify some spare pins in an a specific port in one instruction cycle, without modifying the other pins?, for example: how to output low the pins 1,2,4 of the Portb in one instruction without affecting the rest?
In assembly could be done by masking the bits, but how in C?
2.- Anybody knows why the PORT B cant drive a "74HC"
Thanks
Ysaac |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Thu Oct 18, 2007 2:44 pm |
|
|
You can AND, OR or XOR the port data register. That will change multiple pins of a port in a single clock cycle.
Port B can certainly drive HC logic as well as any other port. Are both the HC and the PIC running from the same VCC? _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
ysaacb
Joined: 12 Jun 2006 Posts: 19
|
|
Posted: Thu Oct 18, 2007 3:47 pm |
|
|
Quote: | You can AND, OR or XOR the port data register |
how?
Quote: | Port B can certainly drive HC logic as well as any other port. Are both the HC and the PIC running from the same VCC? |
I tryed to stream data to a 74HC595 using PB3 and doesn't work. but using PA4 does work |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Fri Oct 19, 2007 2:13 am |
|
|
Portb &= 0xF4; // Will set pins 1,2,4 to low with out altering the others
Current status 10010111
Mask 11110100
New status 10010100
Portb |= 0x0F; // Will set pins 1,2,3,4 and not change pins 5,6,7,8
Current status 10010111
Mask 00001111
New status 10011111 |
|
|
Guest
|
|
Posted: Fri Oct 19, 2007 6:45 am |
|
|
thanks Wayne
I supose the preniously it's necesary to define the adress of PORTB
i.e. #byte PORTB 0xF81 (for the PIC18F4620)
Rigth? |
|
|
|