View previous topic :: View next topic |
Author |
Message |
vino_18_2k6
Joined: 24 Jul 2009 Posts: 4
|
Interface PIC16F887 with PC through RS232 |
Posted: Fri Jul 24, 2009 3:54 am |
|
|
Hi everyone,
I am new to PIC C and am a basic user of CCS C.
I need to connect PIC16F887 with PC through RS232. Can anyone help me with some sample codes to send and receive some datas ?
Via RS232 and display data in Hyperterminal??
Looking for your replies.
Thanks in advance. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jul 24, 2009 11:36 am |
|
|
The following program will display "Start: " in the terminal window.
Then, if you press a key, it will be displayed in the terminal window.
Code: | #include <16F887.H>
#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//====================================
void main()
{
char c;
printf("Start: ");
while(1)
{
c = getc();
putc(c);
}
} |
|
|
|
vino_18_2k6@yahoo.co.in Guest
|
Re: |
Posted: Sat Jul 25, 2009 9:28 am |
|
|
hi
thank you very much.....
i'll try and feedback you..thanks |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
one minor trap |
Posted: Sun Jul 26, 2009 2:38 pm |
|
|
as you say you are new to this part
i would point out that you might wish to make a small change in PCM's
excellent example.
the XT fuse requires an EXTERNAL 4 mhz oscillator -
however the 16f887 has a fine internal one that i use all the time
if you make the following change - you will not need a crystal to get going
Code: |
#fuses INTRC_IO, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000,internal)
|
and best of luck |
|
|
|