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 support@ccsinfo.com

Send string on port different

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



Joined: 07 Feb 2005
Posts: 12

View user's profile Send private message

Send string on port different
PostPosted: Tue Apr 06, 2010 4:45 am     Reply with quote

I would like to send 1 character 8 bit on different port(port a and b) is this possible? How to do?

I m sorry for my english
Very Happy
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Tue Apr 06, 2010 6:10 am     Reply with quote

http://www.ccsinfo.com/faq.php

Look at Input/Output

You will get the answer reading the CCS Compiler manual as first step, there are enough info regarding this.

Humberto
Ttelmah



Joined: 11 Mar 2010
Posts: 19331

View user's profile Send private message

PostPosted: Tue Apr 06, 2010 7:31 am     Reply with quote

I think he is asking about splitting a byte onto two ports.

If so, not simply.

Different answers according to the actual pin layouts involved, how many pins are on each port, etc..
Simplest, test each bit in turn, and output the required bit based on the test. So:
Code:

output_bit(PIN_A4,bit_test(val,0));
output_bit(PIN_A6,bit_test(val,1));
output_bit(PIN_A7,bit_test(val,2));

//etc..

This will work for any bit order, does not require the bits to be consecutive, and allows you to still use 'standard_io' mode. It is surprisingly quick to execute.

Other answer, rotate and mask (if required).
Code:

output_b(val/16); //Put top fout bits of 'val' out on the low four
//bits of port B.
output_a((val*16)+(input_a() & 0xF)); //Put the bottom four bits of
//val, onto the top four bits of port A, at the same time keeping the
//bottom 4 bits of port A unchanged

Obviously, if the low bits here are used as inputs, provided you use 'fast_io' mode, you can set TRIS so only the top four bits are changed by the output, and don't have to mask.

A search here will find a number of answers to this, in particular in relation to LCD's split across ports.

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