PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 18, 2003 3:37 pm |
|
|
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
}
} |
|
|