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

serial communication and lcd problem

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



Joined: 23 Sep 2011
Posts: 10

View user's profile Send private message

serial communication and lcd problem
PostPosted: Mon Oct 10, 2011 9:44 am     Reply with quote

dears,


i am currently on a project that have a variable such that let us assume that the variable
conv=0b01011101

1- i want display the value of conv on the lcd
(so that to be in the lcd 01011101 )
i tried to write
lcd_putc(conv);

but it didn't work

how can i do that

2- my second problem that i want to send the value of variable conv serially to another pic
(so that to transmit the bits 01011101 serially to the other pic )


can any one help me
can any show me a simple ex how to do that?

good luck
temtronic



Joined: 01 Jul 2010
Posts: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Oct 10, 2011 1:55 pm     Reply with quote

while I'm waiting for the bird to be burned....

1) if you want to display the data in BINARY, search this forum, as someone wrote a small progrm to do that....

2) to send it to say another PIC or PC, either look at the examples int he examples folder or read the FAQ section of the onscreen help file( press F11 when project is open).

You should have what you need in less than 1/2 hours of reading....

... time to uncover the bird.
m7md007



Joined: 23 Sep 2011
Posts: 10

View user's profile Send private message

PostPosted: Tue Oct 11, 2011 9:53 am     Reply with quote

Dear temtronic i really appreciate your sarcasm.

But i am new to ccs c for pic.
If you can be more specific in your answer and show me how do it in a real beginner level and show me the steps
i will be grateful.

Thank you in advance.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Oct 11, 2011 10:22 am     Reply with quote

You need to write a loop that rolls through the bits of the variable testing each bit and then sending the proper char.

You can use if() { } else {}
you can use the CCS bit_test() function
you can use ()? : ;

What you want is pretty easy... but like all the others might say, it would not be in your best interest for me to write the code for you as you wouldn't learn yourself for it.

We're happy to guide though.

-Ben

p.s. you don't need to PM us to help, I was already looking at this thread. Cheers.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
m7md007



Joined: 23 Sep 2011
Posts: 10

View user's profile Send private message

PostPosted: Tue Oct 11, 2011 10:29 am     Reply with quote

first of all
thank very much for your reply

your advise was on my mind but i thought that there is a dirct way to show the binary bits for the variable on the lcd

second what about sending the bits serially to another pic

good luck
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Oct 11, 2011 11:17 am     Reply with quote

m7md007 wrote:


your advise was on my mind but i thought that there is a dirct way to show the binary bits for the variable on the lcd


Not by default. I do not believe there is a printf parm that "prints binary" at all. Need to make one.. But it's so easy, that might be why it doesn't exist for CCS PIC-C.

Quote:

second what about sending the bits serially to another pic


Via SPI/I2C/RS232? Is this a separate need for the same project? Is the other PIC the same? Which PIC are you using? You haven't given us enough info.

RS232 is the easy/quick way unless you need more speed. just use putc/fputc to transmit your char to another host -- be mindful of the need for RS232 level conversion hardware (like a MAX232 or MAX221). If you're connecting to another PIC, not needed unless far away -- then it's a good idea.
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
m7md007



Joined: 23 Sep 2011
Posts: 10

View user's profile Send private message

PostPosted: Tue Oct 11, 2011 11:36 am     Reply with quote

thank u for your reply
i will try to write the code for print the binary printing in the lcd

i am programming a pic 16f877a in ccs pcwhd 4.057

for my project i take an input from the keypad and depending on the input i make simple calculation and the result saved in a 8 bit variable called conv

then i want to send the 8 bit variable serially to another pic that display conv in the lcd in the binary form

that is the brief summery of my project
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Oct 11, 2011 11:46 am     Reply with quote

Why are you using 2 pics?

Doesn't an 877 have enough pins to do the LCD and the other stuff?

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
m7md007



Joined: 23 Sep 2011
Posts: 10

View user's profile Send private message

PostPosted: Tue Oct 11, 2011 11:57 am     Reply with quote

the two pic's are connected to each other through an rf wireless module so this module take the data serially from one pic and trasmit it wireless and the rx module receive the data and gave it serially to the second pic

for that to happen i must first let the pic communicate with each other serially and then i will instal the rf module

in a brief word the two pic far from each other
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Tue Oct 11, 2011 12:12 pm     Reply with quote

then for your cabled version, consider using MAX221 (or equivalent) RS232 level translators over your long cable...

and then remove them when going wireless.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
m7md007



Joined: 23 Sep 2011
Posts: 10

View user's profile Send private message

PostPosted: Tue Oct 11, 2011 12:17 pm     Reply with quote

Can you be more detailed?
I am still a beginner.
note: please be patient with me.
m7md007



Joined: 23 Sep 2011
Posts: 10

View user's profile Send private message

PostPosted: Thu Oct 13, 2011 9:40 am     Reply with quote

Thank you bkaman

I solved my problem.

I did the code to display the binary.

and for the serial I defined a char called it conv_a
Code:
char conv_a;


and then
Code:

while (TRUE)
{
conv=conv_a;
putc (conv_a);
}
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