PDA

View Full Version : HSEROUT not working @ 40 MHz



CocaColaKid
- 14th September 2005, 15:35
I running the 18F452 PLL and I'm running into problems with the HSEROUT command. If I use a 4 MHz crystal the LCDOUT command and HSEROUT command work fine. If however I switch out the 4 with a 10 MHz crytal the LCDOUT command still works fine but the HSEROUT output garbage. I have used DEFINE OSC 16 and DEFINE OSC 40 to tell PBP what oscillator speed I'm running. Is there something else I need to do to go to 40 MHz?

CocaColaKid
- 14th September 2005, 15:46
I also just noticed that I have a warning when I define the OSC as 40. The warning is:

Warning[202] c:\pbp\pbppic18.lib 7695: Argument out of range. Least significant bits used.

CocaColaKid
- 14th September 2005, 15:57
After looking through the pbppic18.lib file I noticed that the problem was with the line HSER_TXSTA 24h. It should be HSER_TXSTA 20h.

mister_e
- 14th September 2005, 16:55
mmm yes no toaster hamburger after all. I bet you use HSER_BAUD instead of HSER_SPBRG right?

IF SO it's probably caused by the internal calculation of the SPBRG value.

Wich BaudRate you wanted to use??? Did you look in the datasheet for the SPBRG value with the TXSTA you did???

I'm just curious about that one.

CocaColaKid
- 14th September 2005, 16:57
Just to satisfy your curiosity Mr E :)



DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h

mister_e
- 14th September 2005, 17:02
HEHE i was right... I post a SPBRH Calc on this forum to help to figure out.

BTW here's a short explanation. Using the Calc @9600 baud with 40MHZ with TXSTA = $24 give a SPBRG of 255 with error % 1.725. If you decrease this value the error % increase, so increasing SPBRG will reduce the error %... as SPBRG is a Byte register, you can't or you'll be OUT OF RANGE


Warning[202] c:\pbp\pbppic18.lib 7695: Argument out of range. Least significant bits used.

This is where it's coming from

NOW using SPBRG=20 @40MHZ 9600 bauds gives a SPBRG=64 and error % 0.16

I'm Satisfied now ;)

CocaColaKid
- 14th September 2005, 17:40
Can you post a link to this Calc. This could come in handy in the future.

mister_e
- 14th September 2005, 17:44
here's the link for the download... on this forum
http://www.picbasic.co.uk/forum/attachment.php?attachmentid=316