PDA

View Full Version : Pic18f4550 hserout



Andre_Pretorius
- 8th September 2014, 20:20
Hi Guys, Wonder if any one can point out the difference between the PIC18 and PIC 16 HSEROUT commands.
I normally use the following code in my PIC 16 programs,
'*Serial port Setup 9600 8E1*
DEFINE HSER_BAUD 9600 ; 9600 Baud
DEFINE HSER_BITS 9
DEFINE HSER_EVEN 1
DEFINE HSER_CLROERR 1 ; Clear overflow automatically

I now want to make use of a PIC18F4550
the following code work at 38000 baud
'*Serial port Setup 3800 8N1*
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_SPBRG 56 ' 38400 Baud @ 48MHz, -0.16%
SPBRGH = 1
BAUDCON.3 = 1 ' Enable 16 bit baud rate generator

Is there any way I can get it configured to run 9600 8E1, I have tried changing the HSER_SPBRG value but with no success I also want to activate the parity.

Any leads would be welcomed.

Demon
- 8th September 2014, 20:25
No reason why you couldn't. Have you made sure you're not missing any CONFIG? Try to blink an LED first when in doubt.

Have you tried Mr E's USART Utility to generate the DEFINES?

Robert

Andre_Pretorius
- 9th September 2014, 19:05
It seems to be the 16 bit baud rate generator that is creating the problems as soon as you disable it everything works