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

correct baudrate setting?

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



Joined: 07 Oct 2003
Posts: 66
Location: England

View user's profile Send private message

correct baudrate setting?
PostPosted: Fri Oct 29, 2004 9:33 am     Reply with quote

Hi all

I am trying to set up the baudrate in a 16F767 running at 16.0 mhz, to 250 000.

Can someone please confirm that I have got my settings right from the code below:

spbrg=0x00; // set up
brgh=low; // baudrate to 250.000
sync=0; // enable asynchronous reception
spen=1; // serial port enabled - rc7/rx/dt , rc6/tx/ck pins as serial port pins
rx9=1; // 9 bit reception

Many thanks.

Dave
SherpaDoug



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

View user's profile Send private message

PostPosted: Fri Oct 29, 2004 10:53 am     Reply with quote

Why not:
#use rs232(baud=250000,xmit=rc7,rcv=rc6)

The compiler has no problem with oddball baud rates.
_________________
The search for better is endless. Instead simply find very good and get the job done.
davt



Joined: 07 Oct 2003
Posts: 66
Location: England

View user's profile Send private message

PostPosted: Mon Nov 01, 2004 9:21 am     Reply with quote

Hi Doug

Thanks for your reply.
I need to use the internal hardware usart, I thought the # use rs232 was the software usart?
But any way I want to use the settings:

spbrg=0x00; // set up
brgh=low; // baudrate to 250.000
sync=0; // enable asynchronous reception
spen=1; // serial port enabled - rc7/rx/dt , rc6/tx/ck pins as serial port pins
rx9=1; // 9 bit reception

Will these settings give me 250.000 baudrate @ 16.000 mhz.

Thanks again
Dave
John Morley



Joined: 09 Aug 2004
Posts: 97

View user's profile Send private message

PostPosted: Mon Nov 01, 2004 9:43 am     Reply with quote

Dave,

The #use rs232 statement works for both hardware AND software USART's. The compiler recognizes that you want to use the hardware USART if:

1. the device supports a hardware USART
2. you have specified the hardware USART pins

Otherwise the compiler just creates a software USART with the pins specified.
_________________
John Morley
davt



Joined: 07 Oct 2003
Posts: 66
Location: England

View user's profile Send private message

PostPosted: Mon Nov 01, 2004 10:10 am     Reply with quote

Hi John

How do I incorporate 9th bit reception?

Many thanks.

Dave
John Morley



Joined: 09 Aug 2004
Posts: 97

View user's profile Send private message

PostPosted: Mon Nov 01, 2004 10:34 am     Reply with quote

Dave,

One of the options in the #use rs232 state will do this. Insert Bits=9

#use rs232(baud=9600, xmit=PIN_A2, rcv=PIN_A3, bits=9, .......)

Valid number for Bits= range from 5 to 9.

Good Luck!
_________________
John Morley
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