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

A very simple question, how can I increase the baud rate

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







A very simple question, how can I increase the baud rate
PostPosted: Fri Sep 17, 2004 9:36 am     Reply with quote

Hi,

Compiler : CCS C Compiler
IDE : MPLAB 6.2
PROCESSOR : PIC 16F877

APPLICATION : Datalogger

I have a very simple question, I have developed a datalogger that uses a PIC 16F877 working on 4 Mhz crystal, at present communication is done using RS 485 at a baud rate of 9600.

I find this very slow , now I would like to increase the speed to maximum baud rate possible.

Kindly suggest ....

1. What crystal should I use, 16 MHz, 20 Mhz
2. What fuse setting should I set ( 9600, 19200 etc.)

thankx
arun
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Fri Sep 17, 2004 9:46 am     Reply with quote

I would use an 18.432Mhz xtal. This frequency divides down to an exact standard baud rate.
In your header file, #USE DELAY(CLOCK = 18432000).
Then use SET_UART_SPEED(rate); , rate being equal to the baud rate you want to use. i.e. SET_UART_SPEED(19200);
_________________
David
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Sep 17, 2004 11:14 am     Reply with quote

The USART in the 16F877 can run at 19200 baud with a 4 MHz crystal.
Run this test program to demonstrate that it works.
(Tested with PCM vs. 3.188)

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

//==================
void main()
{
char c;

printf("Hello World\n\r");

// Echo back characters typed in from the keyboard.
while(1)
  {
   c = getc();
   putc(c);
  }

}
bdavis



Joined: 31 May 2004
Posts: 86
Location: Colorado Springs, CO

View user's profile Send private message

PostPosted: Fri Sep 17, 2004 10:38 pm     Reply with quote

If you aren't battery operated, I would go with the higher frequency that is a multiple of the baud rate - your baud rate error will be very low, and you have the extra clocks to do more stuff. There is a reason that certain crystal frequencies are popular. You could also go with a 3.6864 MHz crystal, and still do 115,200 baud, but it could use over 50% processor utilization. (I got a interrupt latency of 40 cycles on the PIC18F452).

IMO... Very Happy
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