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

Clockspeed and Baudrate

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



Joined: 23 Aug 2005
Posts: 93

View user's profile Send private message Visit poster's website

Clockspeed and Baudrate
PostPosted: Tue Jun 13, 2006 8:26 am     Reply with quote

If I try to set a crystal >4Mhz I get an error in my
Code:
#use rs232(baud=300, xmit=PIN_C6, rcv=PIN_C7, bits=7, parity=E, ERRORS, RESTART_WDT)

Baudrate out of range!
I tryed for example a 20MHz, that should according to microchip data give 0.3Kbaud.
But only if Sync=0, BRGH=0 and BRG16=1.
How do I change this parameters (write the bits) thrue CCS inbuilt functions?
By the way, Im using a PIC18F2525.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Jun 13, 2006 10:10 am     Reply with quote

Did you try adding BRGH1OK? I didn't see anything for BRG16 so maybe its tied to that parameter. Another option would be to set it up for another baud rate and then set the SPBRG and SPBRGH registers yourself.
Tagge



Joined: 23 Aug 2005
Posts: 93

View user's profile Send private message Visit poster's website

PostPosted: Tue Jun 13, 2006 10:59 am     Reply with quote

It doesnt seems to help at all.
It seems that the CCS functions dont support this baudrate with this crystal?
Im changing from a 4Mhz crystal to some faster one.
I also use the rs232 settings in different places in my code and I wouldnt want to make any major changes.
If I write the bits manually in the registers then the
#use rs232(300baud..) dont work anywere or?
newguy



Joined: 24 Jun 2004
Posts: 1909

View user's profile Send private message

PostPosted: Tue Jun 13, 2006 11:11 am     Reply with quote

Tagge wrote:
It doesnt seems to help at all.
It seems that the CCS functions dont support this baudrate with this crystal?
Im changing from a 4Mhz crystal to some faster one.
I also use the rs232 settings in different places in my code and I wouldnt want to make any major changes.
If I write the bits manually in the registers then the
#use rs232(300baud..) dont work anywere or?


I think what Mark was getting at was something like this:

- put a "bogus" baud rate in your #use rs232() line - something like 9600 which will work for your PIC and crystal.
- in your program, alter the SPBRG and SPBRGH registers yourself to values that should give you the necessary 300 baud.

If you do it this way, the compiler will be happy and you'll probably be able to get the baud rate you want.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Tue Jun 13, 2006 11:46 am     Reply with quote

newguy wrote:
Tagge wrote:
It doesnt seems to help at all.
It seems that the CCS functions dont support this baudrate with this crystal?
Im changing from a 4Mhz crystal to some faster one.
I also use the rs232 settings in different places in my code and I wouldnt want to make any major changes.
If I write the bits manually in the registers then the
#use rs232(300baud..) dont work anywere or?


I think what Mark was getting at was something like this:

- put a "bogus" baud rate in your #use rs232() line - something like 9600 which will work for your PIC and crystal.
- in your program, alter the SPBRG and SPBRGH registers yourself to values that should give you the necessary 300 baud.

If you do it this way, the compiler will be happy and you'll probably be able to get the baud rate you want.


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