I also use unused characters for the LCD (0x80 - 0x9f) as a controlcode sent to the LCD (RS low) instead of data. I don't use 0x00 as string termination since 0x00 - 0x07 is used for user definable characters, instead I use 0x9f. The controlcodes are defined as constants: ;Values $80-$9f in strings to the LCD is converted to commands (RS=0) ;through a lookuptable LCD_CMD_CLR equ $80 LCD_CMD_HOME equ $81 LCD_CMD_MODE_INC_NO_SCROLL equ $82 LCD_CMD_FUNC_4BIT equ $83 LCD_CMD_DISPOFF equ $84 LCD_CMD_DISPON equ $85 LCD_CMD_DISPON_BLINK equ $86 LCD_CMD_DISPON_CUR equ $87 LCD_CMD_DISPON_CUR_BLINK equ $88 LCD_CMD_CUR_LEFT equ $89 LCD_CMD_CUR_RIGHT equ $8A LCD_CMD_SCROLL_LEFT equ $8B LCD_CMD_SCROLL_RIGHT equ $8C LCD_CMD_HOME_2ND equ $8d LCD_CMD_CGRAM_START equ $8e LCD_CMD_CUR_16 equ $8f LCD_CMD_HOME_STATE equ $90 LCD_END_STR equ $9f Whenever one of these values are found in a string it is substituted through a lookup table before it is sent as a command to the LCD. Here is the lookup table for the above constants. lcd_cmd_table and w,#$1f jmp PC+w retw $01 ;0x80 Clr display retw $02 ;0x81 Cursor Home retw $46 ;0x82 Inc DDRAM no scroll retw $28 ;0x83 4Bit, 1/16, 5*8 retw $08 ;0x84 Display off retw $0c ;0x85 Display on, cur off, blink off retw $0d ;0x86 Display on, cur off, blink on retw $0e ;0x87 Display on, cur on, blink off retw $0f ;0x88 Display on, cur on, blink on retw $10 ;0x89 Move cur left retw $14 ;0x8a Move cur right retw $18 ;0x8b Scroll left retw $1c ;0x8c Scroll right retw $c0 ;0x8d Cursor Home second row retw $40 ;0x8e Set CGRAM adress to 0 retw $8f ;0x8f Cursor to first row col 15 retw $c9 ;0x90 Cursor to second row col 10 Some of these instructions have special meaning for the project they are used in (like Cursor to first row col 15) and since there are 31 possible instructions with this scheme there are room for some of these instructions in the table. Now I can define my strings like this: string_start string_init retw LCD_CMD_FUNC_4BIT,LCD_CMD_DISPOFF,LCD_CMD_DISPON retw LCD_CMD_MODE_INC_NO_SCROLL,LCD_CMD_CLR,LCD_END_STR string_welcome retw '*** HCS 1000 ***',LCD_END_STR string_ready retw LCD_CMD_HOME_2ND,'KLAR ',LCD_END_STR string_cgram1 retw LCD_CMD_CGRAM_START retw $04,$00,$0e,$01,$0f,$11,$0f,$00 retw $11,$00,$0e,$11,$11,$11,$0e,$00 retw $04,$00,$0e,$11,$1f,$11,$11,$00,LCD_END_STR string_cgram2 retw $11,$00,$0e,$11,$1f,$11,$11,$00 retw $00,$10,$08,$04,$02,$01,$00,$00,LCD_CMD_HOME,LCD_END_STR string_first retw LCD_CMD_HOME_2ND,'VER 1.02 000609',LCD_END_STR string_hand retw LCD_CMD_HOME,'AUTO ',LCD_END_STR string_man retw LCD_CMD_HOME,'MANUELL ',LCD_END_STR string_state retw LCD_CMD_HOME_STATE,'FAS ',LCD_END_STR string_is_val retw LCD_CMD_HOME_2ND,LCD_SWG2,'RV. ',LCD_END_STR and only send the offset from string_start to my LCD_sendstring routine. The LCD_sendstring routine also keeps track of the cursor position and increments it correctly at the end of a row (or in the middle of a row in a 1 by 16 LCD). string_cgram1 and string_cgram2 also initaites the first 5 userdefinable characters to some swedish characters normaly not available in the LCD character set. Here are the constants for these characters. LCD_SWV1 equ 0 ;e cg0 LCD_SWV2 equ $e1 ;d existing in normal charset LCD_SWV3 equ $ef ;v existing in normal charset LCD_SWG1 equ 2 ;E cg2 LCD_SWG2 equ 3 ;D cg3 LCD_SWG3 equ 1 ;V cg1 LCD_BSLASH equ 4 ;\ cg4 > Yes, use a table lookup where you have data stored in a table and a > pointer which increments from a starting point until it reaches an end > character (I use .0), sending each one and incrementing the pointer > each time it goes round the loop. > > Martin > > > I'm sending data to an LCD using the following method: > > > > movlw 0x54 ;T > > call SendLCDData > > movlw 0x65 ;e > > call SendLCDData > > movlw 0x73 ;s > > call SendLCDData > > movlw 0x74 ;t > > > > where SendLCDData is: > > SendLCDData ; Sends a byte as a data to the LCD. > > bsf PORTC,6 ; LCD_RS_BIT > > movwf PORTD ; OK. Data is on the LCD data > > pins bsf PORTC,7 ;LCD_E_BIT bcf PORTC,7 ;LCD_E_BIT > > call Delay_50MS retlw 0 > > > > This works just fine...but I'm thinking not very efficient? Is there > > a better way to send ASCII strings to a LCD? > > > > > > > > ____________________________________________________________________ > > Get free email and a permanent address at > > http://www.netaddress.com/?N=1 > > > > -- > > http://www.piclist.com hint: The list server can filter out > > subtopics (like ads or off topics) for you. See > > http://www.piclist.com/#topics > > > > > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > ============================== Ruben Jvnsson AB Liros Elektronik Box 9124, 200 39 Malmv, Sweden TEL INT +46 40142078 FAX INT +46 40947388 ruben@pp.sbbs.se ============================== -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.