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

Writing 10 bits to a splite I/O ports

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







Writing 10 bits to a splite I/O ports
PostPosted: Sun Dec 21, 2003 7:49 am     Reply with quote

I'm using the 16F819, and I want to write 10 bits to I/O's.
The bits are split and mix between port A and port B.
Is there a nice way of doing it.

Thanks,
Edi
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sun Dec 21, 2003 9:45 am     Reply with quote

Depends on how the IO is split. If the 2 MSB are on A1 & A0 and the lower 8bits are on port B then it is very simple. You can use the make8() function to assign the upper byte to portA and the lower byte to portB. However, if there are other outputs on portA then instead of assigning the value to portA, you will need to AND 0xFC and then OR the upper byte. This might not be the best way (AND/OR) as the output might go low for a couple of instruction cycles after the AND. A lot depends on what you are trying to do. You can also create a union and overlay that onto portA and portB since their addresses are sequential. Give a little more detail and what you are writing this 10bit value to.
Edi
Guest







PostPosted: Sun Dec 21, 2003 1:52 pm     Reply with quote

I want to light a 7 segment but I have only 4 I/O free in port A and 6 in port B.
Can you please post a samples, how it can be done without a bit logic AND/OR to activate the 7 segment.
The bits are not in order.
What is make8()?
Edi
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sun Dec 21, 2003 5:15 pm     Reply with quote

In that case, the simplest is bit_test and output_high/output_low
Code:

long var_10bit;

if (bit_test(var_10bit,0))
  output_high(PIN_A0);
else
  output_low(PIN_A0);
.
. other bit tests go here.
.
if (bit_test(var_10bit,9))
  output_high(PIN_B3);
else
  output_low(PIN_B3);

Edi
Guest







PostPosted: Mon Dec 22, 2003 8:53 am     Reply with quote

Thanks for your answer.

Isn't there a way to write it in one line, like: struct10bit = value;
and each bit will ge it's value.

Thanks,
Edi
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