FIXED and now i know why i stuffed up
for those that do not know how to caclulate the baud rates for osc speeds not common
at least is shows how its done for the k40 series
reason for the error is that in the data sheet the parameter BRGH and SPxBRGH are not the same and i was setting it incorrectly when changing for calculations
all baud rate calcs refer to setting BRGH found in TXxSTA bit3
also so by setting DEFINE HSER2_SPBRGH 0 and DEFINE HSER2_SPBRGL 52 - did not work , dEFINE HSER2_SPBRG 52 works
by using calc2 gives the lowest error rate for 19.2k baud
so requires 8bit/async BRGH = 1 , BRG16 =0
Code:
DEFINE HSER_PORT 2 ' Hser port 2 use
DEFINE HSER2_RXREG PORTB ' USART 2 RX - Set PPS Register port B
DEFINE HSER2_RXBIT 7 '
DEFINE HSER2_TXREG PORTB
DEFINE HSER2_TXBIT 6
DEFINE HSER2_RCSTA 90h ' Hser2 receive status init - async
DEFINE HSER2_TXSTA 24h ' Hser2 transmit status init - async BRGH = 1 ( BIT3)
dEFINE HSER2_CLROERR 1 ' Clear overflow automatically
DEFINE HSER2_BAUD 19200 ' Hser2 baud rate
DEFINE HSER2_SPBRG 212 ' 19200 Baud @ SPBRG = 212 0.0016% error
BAUD2CON.3 = 0 ' set BRG16 = 0 - 8BIT/ASYNC
Bookmarks