PDA

View Full Version : Serial comunication osc 20Mhz and baud 38400 donīt work



visitac
- 1st June 2013, 17:18
Hello

I try hardware serial communication with PIC 18F4520 baudrate 38400 but unfortunatly without sucess
Have anyone sucess with this. What make i wrong?

DEFINE OSC 20

BAUDCON.3 = 1 'SETUP FOR HIGH SPEED.
DEFINE HSER_RCSTA 90H
DEFINE HSER_TXSTA 24H 'HIGH SPEED MODE BAUD RATE GENERATOR
DEFINE HSER_BAUD 38400
DEFINE HSER_SPBRG 38H '38400 BAUD
DEFINE HSER_SPBRGH 01H
Hserout ["DISPLAY"]
'
Have tried this too, but donīt work
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h ;HIGH SPEED BRG SET
DEFINE HSER_SPBRG 110 ;38400 BAUD
DEFINE HSER_CLROERR 1 ;AUTO CLEAR ERRORS
Hserout ["DISPLAY-B"]

Can anyone help?
Thanks in advance
visitac

Ceetee
- 1st June 2013, 20:53
Hi Visitac

Will this work for you.

define OSC 20
define HSER_CLROERR 1 ' Automatically clear over-run errors
define HSER_SPBRG 32 ' 32 = 38400 at -1.36%error MisterE Calc software
define HSER_RCSTA 90h ' Enable USART receive
define HSER_TXSTA 24H ' Set TXSTA to allow for higher baud rate

Hserout ["DISPLAY-B"]

Not tried 18F4520 but works on 18F4331 OK (from what I remember, long time ago).

Chris

Charlie
- 2nd June 2013, 10:30
A quick look at the datasheet suggests it is never going to run at that rate.
Try 9600 and see how that works.

visitac
- 2nd June 2013, 14:29
Hello Ceetee,

Thank You, i will try it on Monday

Charlie, i donīt see on the datasheet why it can not work with 38400 baud

Best regards
visita



Hi Visitac

Will this work for you.

define OSC 20
define HSER_CLROERR 1 ' Automatically clear over-run errors
define HSER_SPBRG 32 ' 32 = 38400 at -1.36%error MisterE Calc software
define HSER_RCSTA 90h ' Enable USART receive
define HSER_TXSTA 24H ' Set TXSTA to allow for higher baud rate

Hserout ["DISPLAY-B"]

Not tried 18F4520 but works on 18F4331 OK (from what I remember, long time ago).

Chris