Hi all here is the code I use now and it works, 48M crystal on a PIC18F4550
Next will be parity, I will copy the code again when it works
If bRate = 0 THEN
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $24 ' Enable transmit, BRGH = 1
SPBRG = 225 ' 9600 Baud @ 0.0%
SPBRGH = 4
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
ENDIF
If bRate = 1 THEN
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $24 ' Enable transmit, BRGH = 1
SPBRG = 112 ' 19200 Baud @ 0.0%
SPBRGH = 2
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
ENDIF
If bRate = 2 THEN
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $24 ' Enable transmit, BRGH = 1
SPBRG = 56 ' 38400 Baud @ -0.16%
SPBRGH = 1
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
ENDIF
If bRate = 3 THEN
RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $20 ' Enable transmit, BRGH = 0
SPBRG = 51 ' 57600 Baud @ 0.16%
SPBRGH = 0
BAUDCON.3 = 1 ' Enable 16 bit baudrate generator
ENDIF
Bookmarks