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

Specific Output to I/O PORT

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



Joined: 11 Feb 2004
Posts: 51

View user's profile Send private message

Specific Output to I/O PORT
PostPosted: Fri Apr 09, 2004 12:55 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Apr 09, 2004 1:17 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Apr 09, 2004 1:22 am     Reply with quote

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
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