View previous topic :: View next topic |
Author |
Message |
Tagge
Joined: 23 Aug 2005 Posts: 93
|
Clockspeed and Baudrate |
Posted: Tue Jun 13, 2006 8:26 am |
|
|
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
|
|
Posted: Tue Jun 13, 2006 10:10 am |
|
|
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
|
|
Posted: Tue Jun 13, 2006 10:59 am |
|
|
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: 1907
|
|
Posted: Tue Jun 13, 2006 11:11 am |
|
|
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
|
|
Posted: Tue Jun 13, 2006 11:46 am |
|
|
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 |
|
|
|