View previous topic :: View next topic |
Author |
Message |
ernest
Joined: 11 Feb 2004 Posts: 51
|
Specific Output to I/O PORT |
Posted: Fri Apr 09, 2004 12:55 am |
|
|
Hi,
I'm quite familiar with MPLAB IDE assembly languange but I am new to CCS C-compiler. I would like to output specific logic values to the I/O ports of PIC.
Let's say I have a few binary values ranging from 0-9 respectively that I need to output to the I/O port for BCD eg. binary value of 6 equivalent to 0110 to be sent to lower nibble of PORTB (RB0 - RB3). The higher nibble of PORTB is being used for something else.
So, how can I go about doing that without affecting the higher nibble?
If I were to use the 'OUTPUT_B(0X06)' command, the whole portb will be changed thus affecting the higher nibble.
Thanks a lot. |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Fri Apr 09, 2004 1:17 am |
|
|
Something like this would do:
Code: |
byte port_b_temp;
port_b_temp=input_b();
port_b_temp&=0xF0;
port_b_temp|=0x06;
output_b(port_b_temp);
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Apr 09, 2004 1:22 am |
|
|
Or, use a structure of bitfields as shown in the driver file, LCD.C.
Look at some of the functions in that file to see how they write
to the structure elements, and thus to groups of pins on Port B.
This file is in c:\Program Files\Picc\Drivers |
|
|
|