Help with LCD's
I had a 20x4 LCD (parallel) laying around and this afternoon I was messing with it. I got it to initialize and display whatever cursor I specify and I am able to send data to it and have it display it. However, I want to be able to send a string a data to it instead of sending it character by character. I messed around with lookup tables (just input the string in a table, each character separated by a comma) and it works, but thats a really dumb solution...
So basically I'm asking if there is a way to split a string up into individual characters so I can output one, then move to the next, output it, etc, etc.
Anyone have a solution?
Thanks in advance!
-Dan
So basically I'm asking if there is a way to split a string up into individual characters so I can output one, then move to the next, output it, etc, etc.
Anyone have a solution?
Thanks in advance!
-Dan

Comments
What I've been doing is to declare a string so it ends with a zero, like this -
hello dw 'Hello World! ',0
To display the string, write its address to the W register, then call the write_string routine -
mov W, #hello
call @lcd_write_string
The write_string routine copies the contents of W to an address pointer, which it then steps along, displaying each individual character until it reaches a zero -
_lcd_write_string
bank48 bank_LCD
mov string, W
:loop
bank48 bank_LCD
mov W,string
mov M, #0
iread ; reads value from 11-bit code address in M, W
test W
jz @:end
call @lcd_write_data
bank48 bank_LCD
inc string
jmp @:loop
:end
retp
Does that help?
David
Thanks a lot!
-Dan
The example also uses a zero byte to terminate a text string. This is a common practice. If you place the text of the string in quotes SX/B includes the terminating zero byte for you automatically in the generated code.
- Sparks
tempW VAR WORD temp VAR BYTE LCD_Char SUB 1 ' Pass character to print LCD_Str SUB 2 ' Pass string to print Program Start Start: LCD_Str "Hello there" LCD_Str Message1 END SUB LCD_Char ' What ever code you need here ENDSUB SUB LCD_Str tempW = __WPARAM12 DO READINC tempW, temp IF temp = 0 THEN EXIT LCD_Char temp LOOP ENDSUB Message1: Data "This is a message", 0 ' Don't forget the zero at the end▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·