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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
www.iElectronicDesigns.com
·