Darrel this incorporates your USART macro (works great):
Code:
DEFINE LOADER_USED 1 ' use for Boot Loader
DEFINE OSC 40 ' change to suit oscillator speed
'============================================
' Equates
'============================================
temp var byte ' temporary storage for character
Goto main ' skip around Macros
'============================================
' Macros
'============================================
' Send String Macro (must be located prior to Main)
ASM
SendStr macro Astring
call _prntSTR
data Astring,0
endm
ENDASM
' USART Initialization Macro (must be located prior to Main)
' [ Initialize 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
'============================================
' Main Program
'============================================
Main:
@ USART_Init 19200 ; set RS232 baudrate
' send messages through RS232
' format #1
@ SendStr "This is a string"
@ SendStr "yet another string again"
@ SendStr "and one more time!"
' format #2
ASM
SendStr "This is a string"
SendStr "yet another string again"
SendStr "and one more time!"
ENDASM
Done:
Goto Done ' loop forever
'============================================
' String Extraction and Print Routines
'============================================
' print string code (locate anywhere)
ASM
_prntSTR
;copy return address to TBLPTR and then pop it off the stack
movf TOSU,W
movwf TBLPTRU
movf TOSH,W
movwf TBLPTRH
movf TOSL,W
movwf TBLPTRL
POP
;TBLPTR should now be pointing to 1st character in string
Next_Char
tblrd *+ ; table read and post increment TBLPTR
movff TABLAT,_temp ; fetch character from message string
bra Test_EOM ; go test for EOM character
Continue ; If not EOM then...
movf _temp,W ; move character into TXREG and...
movwf TXREG ; send it!
btfss TXSTA,TRMT ; has it been transmitted?
goto $-2 ; If not, keep checking
bra Next_Char ; fetch next message character from table
Test_EOM
movlw .0 ; check for EOM character
cpfseq _temp,W ; compare temp with w, if temp = 0 then end
bra Continue ; no EOM, so continue
movlw "\r" ; move carriage return into TXREG and...
movwf TXREG ; send it!
btfss TXSTA,TRMT ; has it been transmitted?
goto $-2 ; If not, keep checking
movlw "\n" ; move line feed into TXREG and...
movwf TXREG ; send it!
btfss TXSTA,TRMT ; has it been transmitted?
goto $-2 ; If not, keep checking
;use incremented value of TBLPTR as new return address (push it)
PUSH
movf TBLPTRU,W
movwf TOSU
movf TBLPTRH,W
movwf TOSH
movf TBLPTRL,W
movwf TOSL
return ;finished with message, return to caller
ENDASM
Bookmarks