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

Interface PIC16F887 with PC through RS232

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



Joined: 24 Jul 2009
Posts: 4

View user's profile Send private message

Interface PIC16F887 with PC through RS232
PostPosted: Fri Jul 24, 2009 3:54 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jul 24, 2009 11:36 am     Reply with quote

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:
PostPosted: Sat Jul 25, 2009 9:28 am     Reply with quote

hi

thank you very much.....

i'll try and feedback you..thanks
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

one minor trap
PostPosted: Sun Jul 26, 2009 2:38 pm     Reply with quote

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