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

How to display serial Data to PORTD?

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



Joined: 09 Sep 2003
Posts: 52

View user's profile Send private message MSN Messenger

How to display serial Data to PORTD?
PostPosted: Thu Dec 18, 2003 2:47 pm     Reply with quote

I want to display a number which is press from PC keyboard and convert it into HEX or Binary and display it in PORTD

Anyone got information or a subroutine that I can use?

Please help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Dec 18, 2003 3:37 pm     Reply with quote

I assume that your PC is connected to your PIC demo board,
by a RS-232 cable ? If so, then the entire program that
you describe is only a few lines of code. To solve
a problem like this, you should look in the CCS manual
and try to find some built-in functions which will accomplish
your task. In this case, you want to get characters from
the PC. So, the getc() looks good for this. You also want
to write them to Port D. So, the output_d() function will
work for this. Here is a link to the manual:
http://www.ccsinfo.com/ccscmanual.zip

For most of the programs that you, as a newbie, want to write,
CCS already has a function that will solve your problem.
If you read the manual, you will find those functions.

Here is the program that solves your problem.
See the manual to understand why I picked the
CCS functions that are shown below.

Code:
#include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud = 9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)   

main()
{
char c;

while(1)
  {
   c = getc();    // Get the Ascii number
   c = c - 0x30;  // Convert it to binary (remove Ascii bias)
   output_d(c);   // Send it to Port D
  }

}
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