View previous topic :: View next topic |
Author |
Message |
g-netix
Joined: 19 Aug 2012 Posts: 19
|
UART BRGH10K error |
Posted: Wed Jul 17, 2013 1:28 pm |
|
|
Hi!
I want to implement a DMX transmitter and receiver, but I can't use a baud rate of 250k because of when I compile I get the error "BRGH10K out of range" while it has been generated by the Wizard.
I use a PIC18F46K22 @24 MHz (external CMOS/TTL oscillator)
I use the version v4.141 but I tried in the demo of v5 and still the same problem...
Hope you'll be able to help me.
Thank's!
PS : I didn't write anything else, I just compiled what was generated by the Wizard... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jul 17, 2013 1:58 pm |
|
|
The problem is not the UART speed. The problem is a spelling error.
You have "BRGH10K", where you have "10K" on the end, like a resistor.
But it's supposed to be BRGH1, with "OK" on the end, like the American
slang for "good" or "it's allowed".
With corrected spelling, this program compiles with no errors (with vs. 4.141):
Code: | #include <18F46K22.h>
#fuses ECH_IO, NOWDT
#use delay(clock=24M)
#use rs232(baud=250000, UART1, ERRORS, BRGH1OK)
//======================================
void main(void)
{
char c;
c=getc();
putc(c);
while(1);
} |
|
|
|
g-netix
Joined: 19 Aug 2012 Posts: 19
|
|
Posted: Thu Jul 18, 2013 10:47 am |
|
|
Ok thank you it works! I don't understand why it doesn't work when it's generated by the Wizard, but I renamed it as you said and it works fine. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Jul 18, 2013 4:10 pm |
|
|
perhaps your version of the Wizard
"kent spill viry will" |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19541
|
|
Posted: Fri Jul 19, 2013 4:20 am |
|
|
You will find that few of the relatively 'experienced' people here ever use the Wizard. It has quite a few bugs....
Best Wishes |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Jul 19, 2013 7:21 am |
|
|
It is a bug that went long time unnoticed because the BRGH1OK parameter is only added for the higher baud rates. At 24MHz clock and 115k2 baud the BRGH1 register isn't used and the erroneous parameter isn't added.
As I got the impression nobody reported the bug to CCS I sent them an email. |
|
|
Scottzilla
Joined: 17 Jul 2012 Posts: 14
|
|
Posted: Sat May 27, 2017 2:43 pm |
|
|
4 years later and the wizard still spells BRGH1OK wrong! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19541
|
|
Posted: Sat May 27, 2017 2:48 pm |
|
|
and the same answer still applies.
To use the Wizard, you have to know every setting for the chip. If you know the settings, it is better to set them yourself. Result, nobody actually doing anything beyond very initial learning, actually uses the Wizard. There are several dozen faults that the Wizard routinely generates. Honestly the compiler would be better without the Wizard.... |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19541
|
|
Posted: Sun May 28, 2017 8:21 am |
|
|
As a separate comment to this though, it is really silly that we still have the BRGH1OK setting.
Historically, on the earliest PIC's when CCS first started, this was one of the first major errata. Since there were almost no others, they made the compiler default to not setting the BRGH bit, and added this option for the chips where it was OK. Now though we have literally hundreds of errata affecting many chips. Instead of allowing a setting like this, these are now stored as part of the chip data with fixes automatically being applied. Surely it'd make more sense now to get rid of this setting (leave it as an option for 'reverse compatibility'), but have the compiler default to supporting BRGH being set to '1' unless the chip has this stored as an erratum. Especially since now there are perhaps 100 PIC's without this problem for every one with.... |
|
|
|