Hiya Michael,
And for my next installment of things you can change with the program you already have working .... 
Sometimes I go crazy with the macro's. But I kinda like this one.
Code:
'--[ Initialise USART for specified baud rate at current OSC speed ]------------
ASM
USART_Init macro Baud
clrf TXSTA, 0
_SPBRG = (OSC * 1000000) / 16 / Baud - 1 ; calc SPBRG @ High baud rate
if _SPBRG > 255 ; if SPBRG is too high
_SPBRG = (OSC * 1000000) / 64 / Baud - 1 ; calc for Low baud rate
bcf TXSTA, BRGH, 0 ; Set BRGH to Low Speed
if _SPBRG > 255
_SPBRG = 255
endif
else
bsf TXSTA, BRGH, 0 ; Set BRGH to High Speed
endif
bsf TXSTA, TXEN, 0 ; Set Transmit Enable bit
movlw _SPBRG
movwf SPBRG, 0 ; load the calulated SPBRG
movlw B'10010000' ; enable USART
movwf RCSTA, 0
endm
ENDASM
Now to initialize the USART all you have to do is this...It should work with any OSC setting and any valid baud rate.
-------------------------
>> Ulimately, it will hopefully evolve into a great way to send either message strings, data, or both to any device you wish.
I've also got some MAJOR changes that allow you to do the above quote. Haven't tested them completely yet, but they look promising.
Best regards,
Darrel
Bookmarks