Thanks Bruce, it works great!
And now here it is utilizing your RS232 code:
This is real sweet, because all you have are 2 lines of code to send a message, and without any limitations as to how many or where they are located (assuming it fits in the program space).Code:DEFINE LOADER_USED 1 DEFINE OSC 40 ' change to suit oscillator speed temp var byte Main: CALL USART_Init Call prntSTR @ data "This is a string",0 Call prntSTR @ data "yet another string again",0 Call prntSTR @ data "and one more time!",0 Done: Goto Done asm _USART_Init movlw B'00100100' ; initialize USART movwf TXSTA ; 8-bit, Async, High Speed movlw .129 ; value for 19200 bps @ 40MHz movwf SPBRG ; set SPBRG for 19200 bps @ 40MHz movlw B'10010000' ; enable USART movwf RCSTA return _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
Well this is what I wanted in the first place, all it took was a bit of head scratching and some terrific help from you and Darrel. Heck until I started reading through the PIC18F reference material, I had assumed that there was no way to PUSH and POP a PIC chip (BTW, that is a great link to all kinds of good information).
Next: Do the same thing for an LCD. Anyone got some good LCD asm code and an LCD to try it on?
(yet another challenge for some brave soul)
EDIT: Opps!! Darrel I guess you'll have to move this as well... Sorry
see ya,




Bookmarks