19200 baud @4MHZ... by the datasheet table 12-5 it's suppose to work. But i'll prefer to set USART in a different way.
What about if you remove the
DEFINE HSER_TXSTA 20h
' Set baud rate
DEFINE HSER_BAUD 19200
and you replace it by
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h 'enable TXEN and BRGH=1
DEFINE HSER_SPBRG 12
these will give you 19231 baud +/-0.16% (depending the oscillator precision too)
On the other side¸
@40MHZ
remove :
DEFINE HSER_BAUD 19200
change it to:
DEFINE HSER_TXSTA 24h 'enable TXEN and BRGH=1
DEFINE HSER_RCSTA 90h
DEFINE HSER_SPBRG 129
this will also give you 1923x baud +/-0.16%
Always remind SPBRG change with the clock speed. Have to check in the datasheet.
For this speed of serial comm, i'll prefer use else than the internal oscillator. I'm a bit surprise that it can work @19200 baud with a simple 4MHZ crystal.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks