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

Could I find any RS232 example code for PIC16F1947 ?

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



Joined: 09 May 2011
Posts: 6

View user's profile Send private message

Could I find any RS232 example code for PIC16F1947 ?
PostPosted: Tue May 10, 2011 11:26 pm     Reply with quote

I'm trying to verify whether my pcb RS232 function is normal or not by HyperTerminal.

I can't do it very well for many until now. Where could I find this kind of example code?

Thanks a lot!!!
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed May 11, 2011 6:21 am     Reply with quote

The code should be similar for any PIC16Fxxxx chip. On the other hand HyperTerminal is awful. Use SIOW that comes with CCS or Realterm or Terminal by Brady++ or any one of the other better terminal programs for the PC.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Wed May 11, 2011 7:11 am     Reply with quote

Please heed the advice not to use Hyperterminal. When new to RS232 the last thing you need is to deal with the quirks of Hyperterminal. Next remember that RS232 is asynchronous so a character can arrive and will arrive at anytime not just at the ends of lines of code or sections of your main code. The robust way is to write an interrupt driven circular buffer. Except for the simplest use you'll find you'll need a circular buffer anyway. This board has many questions about wayward RS232 code most of which would have been avoided by use of an interrupt driven circular buffer.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed May 11, 2011 12:49 pm     Reply with quote

Here is a sample program. When you type a character in a terminal
window on your PC, this program should receive and send it back to
the PC, where it will be displayed.
Code:

#include <16F1947.h>
#fuses INTRC_IO,NOWDT,BROWNOUT,PUT
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS)
 
//====================================
void main()
{
int8 c;

printf("Start \n\r");

while(1)
  {
   c = getc();
   putc(c);
  }
 
}
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