HIGHBYTE / LOWBYTE help
TC
Posts: 1,019
I am working on a project that I must send the LOWBYTE of a WORD then send the HIGHBYTE of the same WORD. I do not want to ues anymore variables. Here is the code I am working on.
Graphics_Home_Address:
· GOSUB Status_check_1
· LCD_data = graphics_address.LOWBYTE '<--·first send the LOWBYTE of WORD
· GOSUB write_data
· GOSUB Status_check_1
· LCD_data = graphics_address.HIGHBYTE '<-- then send the HIGHBYTE of WORD
· GOSUB write_data
· GOSUB Status_check_1
· LCD_data = Graphic_home_addr
· GOSUB write_command
· RETURN
This code does not work.
Please help, and thanks
TC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
We all make mistakes when we are young………That’s why paste is edible!
Post Edited (TC) : 12/12/2006 2:12:25 AM GMT
Graphics_Home_Address:
· GOSUB Status_check_1
· LCD_data = graphics_address.LOWBYTE '<--·first send the LOWBYTE of WORD
· GOSUB write_data
· GOSUB Status_check_1
· LCD_data = graphics_address.HIGHBYTE '<-- then send the HIGHBYTE of WORD
· GOSUB write_data
· GOSUB Status_check_1
· LCD_data = Graphic_home_addr
· GOSUB write_command
· RETURN
This code does not work.
Please help, and thanks
TC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
We all make mistakes when we are young………That’s why paste is edible!
Post Edited (TC) : 12/12/2006 2:12:25 AM GMT
Comments
·
·· Should the writes be consecutive maybe?· I would think if the device required a word value that you would send both pieces without doing the Status check…But then I don’t know what device you’re writing to.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I am trying to hone my PBASIC programing skills.
Thanks
TC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
We all make mistakes when we are young………That’s why paste is edible!
It might be a bit easier to troubleshoot this problem if the entire program were attached to your post as a text file.
Regards,
Bruce Bates
Thanks
TC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
We all make mistakes when we are young………That’s why paste is edible!
I honestly never thought of using HIGHBYTE/LOWBYTE with a constant, and I've no idea if it will work. In lieu of what you have, you might try this:
Graphics_address VAR WORD
Graphics_address = %0001000000000000 'Adjust constant as necessary
Then see how that goes. Now can you see why seeing the program was necessary? I had no idea how you had defined Graphics_address, etyc.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
thanks
TC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
We all make mistakes when we are young………That’s why paste is edible!
I realize it's been 8 months since your post but here is what I did to get the highbyte and lowbyte
temp = (char-32) & %00001111
DEBUG BIN(temp), ","
GOSUB SENDDATA
temp = ((char-32) & %11110000)
temp = temp / 16
DEBUG BIN(temp), ","
GOSUB SENDDATA
I am having problems my screen shows nothing but it may be an issues with the lcd I bought, but I haven't gone through your code yet. You did mention you might change it, if you did could you share it?
Here's what I have done.
'=============================================================
' File...... Parallel LCD 240 X 64 Display with T6963c Control Chip
' Purpose... Parallel LCD Display Demo (Text)
' Author.... Michael A. Cyples
' E-mail.... Cyplesma@aol.com
'{$STAMP BS2}
'{$PBASIC 2.5}
START:
comSetGrHome VAR Byte
comSetGrArSet VAR Byte
comSetTxHome VAR Byte
comSetTxArSet VAR Byte
comTGMSOR VAR Byte
comTGMSAND VAR Byte
comTGMSXOR VAR Byte
comTAMGR VAR Byte
txtATGr VAR Nib
txtATTx VAR Nib
txtATCr VAR Nib
txtATBC VAR Nib
apcPtrInit VAR Byte
apcWRDec VAR Byte
apcWRnmp VAR Byte
apcWRInc VAR Byte
apcRDDec VAR Byte
apcRDnmp VAR Byte
apcRDInc VAR Byte
curHgt4 VAR Byte
'
[noparse][[/noparse] Program Description ]
' This program demonstrates using the T6963c-compatible Parallel LCD Display
' This code works with the BS2
'
[noparse][[/noparse]T6963c Notes ]
'
' Read Data - C/\D take low
' /RD take low (/WR should be high)
' /CE take low
' After 150ns read the data on D0 - D7
' /CE take high
'
'
'
[noparse][[/noparse] I/O Definitions ]
CE PIN 10 ' Chip Enable Pin for LCD
RS PIN 9 ' Read Pin for LCD
WS PIN 8 ' Write Pin for LCD (Should always
' be oppisite of RS
CD PIN 11 ' C/D Signal
RT PIN 12 ' Reset
'
[noparse][[/noparse] LCD Commands ]
comSetGrHome = 66 ' Set Graphics Home - Start Graphics Memory Area
comSetGrArSet = 67 ' Set Graphics Area Set - Length of Graphic line
comSetTxHome = 64 ' Set Text Home - Start Text Memory Area
comSetTxArSet = 61 ' Set Text Area Set - Length of Text
' Text/Graphics Display Mode Sets
comTGMSOR = 128 ' text pixel OR graphic pixel
comTGMSAND = 129 ' text pixel AND graphic pixel
comTGMSXOR = 130 ' text pixel XOR graphic pixel
' + 8 to get Text Character from RAM (User - Defined)
' Text Attribute Modes
comTAMGR = 144 ' Base Command Code must use with following:
txtATGr = 8 ' comTAMGR + 8 Turn Graphics ON
txtATTx = 4 ' comTAMGR + 4 Turn Text ON
txtATCr = 2 ' comTAMGR + 2 Turn Cursor ON
txtATBC = 1 ' comTAMGR + 1 Blink Cursor
' Address Pointer Commands
apcPtrInit = 36 ' Initialize pointer send 0123h (two data bytes,
' data 01, data 23, command 24)
apcWRDec = 194 ' Write data, then Decrease Pointer
apcWRnmp = 196 ' Write data, leave pointer unchanged
apcWRInc = 192 ' Write data, then Increase Pointer
apcRDDec = 195 ' Read data, then Decrease Pointer
apcRDnmp = 197 ' Read data, leave pointer unchanged
apcRDInc = 193 ' Read data, then Increase Pointer
' Cursor Height Commands
curHgt4 = 164 ' Set Cursor Height to 4 Lines
'
[noparse][[/noparse] Variables ]
char VAR Byte ' Character sent to LCD
inst VAR char ' Instruction To send to LCD
index VAR Word ' Character Pointer
temp VAR Byte ' Temp Variable
status VAR Byte ' Status variable
'
[noparse][[/noparse] EEPROM Data ]
Message DATA "X9X8X7X6X5X4X3X2X1X0XAXBXCXDXEXFXGXHXIXJXKXLXMXNXOXPXQXRXSXTXUXVXWXXXYXZ",0
' Message to send to LCD
'
[noparse][[/noparse] Initialization ]
OUTL = %00000000
DIRL = %11111111
OUTH = %00000000
DIRH = %11111111
INITLCD: ' Initialize LCD Display
DEBUG "START", CR
PAUSE 200
HIGH RT
PAUSE 20
LOW RT
GOSUB CheckStat
DEBUG "STAT", CR
temp = 0
GOSUB SENDDATA
temp = 32
GOSUB SENDDATA
inst = comSetTxHome
GOSUB SENDCOM
temp = 0
GOSUB SENDDATA
temp = 0
GOSUB SENDDATA
inst = comSetGrHome
GOSUB SENDCOM
temp = 32
GOSUB SENDDATA
temp = 0
GOSUB SENDDATA
inst = comSetTxArSet
GOSUB SENDCOM
temp = 32
GOSUB SENDDATA
temp = 0
GOSUB SENDDATA
inst = comSetGrArSet
GOSUB SENDCOM
inst = comTGMSOR
GOSUB SENDCOM
inst = comTAMGR + txtATGr + txtATTx + txtATCr + txtATBC
GOSUB SENDCOM
temp = 0
GOSUB SENDDATA
temp = 32
GOSUB SENDDATA
inst = apcPtrInit
GOSUB SENDCOM
inst = curHgt4
GOSUB SENDCOM
temp = 36
GOSUB SENDDATA
temp = 3
GOSUB SENDDATA
inst = 33
GOSUB SENDCOM
inst = 156
GOSUB SENDCOM
DEBUG "done init", CR
GOSUB DISTEXT
STOP
'
CheckStat: ' Check Status
' Read Status - To check the status of the T6963c controller
' C/\D take high
' /RD take low (/WR should be high)
' /CE take low
' After 150ns read the data on D0 - D7
' /CE take high
DIRL = %00000000
HIGH CD
LOW RS
HIGH WS
LOW CE
PAUSE 50
HIGH CE
IF IN1 = 1 THEN
DEBUG "ERROR"
PAUSE 400
ENDIF
DEBUG IN0, " - 0", IN1, " - 1 BL", CR
DO UNTIL IN0 = 1 AND IN1 = 1
DEBUG IN0, " - 0", IN1, " - 1 IL", CR
LOOP
RETURN
'
SENDDATA: ' Send Data Byte
'GOSUB CheckStat
' Write Data - The Data to be written should be set on D0 - D7 and
' C/\D taken low
' /WR taken low (/RD should be high)
' /CE pulsed low for greater then 80ns
DIRL = %11111111
OUTL = temp
HIGH CD
PAUSE 1
LOW CD
LOW WS
HIGH RS
HIGH CE
LOW CE
PAUSE 1
HIGH CE
RETURN
'
SENDCOM: ' Send Command Byte
GOSUB CheckStat
' C/\D take high
' /RD take high (/WR should be low)
' /CE take low
DIRL = %11111111
OUTL = inst
LOW CD
PAUSE 1
HIGH CD
LOW WS
HIGH RS
LOW CE
RETURN
'
DISTEXT: ' Display TEXT on LCD
index = message
char = 85
GOSUB SENDDATA
inst = 224
GOSUB SENDCOM
XXXX:
READ index, char
IF char <> 0 THEN XX11
STOP
XX11:
PAUSE 300
DEBUG char, CR
temp = (char-32) & %00001111
DEBUG BIN(temp), ","
GOSUB SENDDATA
temp = ((char-32) & %11110000)
temp = temp / 16
DEBUG BIN(temp), ","
GOSUB SENDDATA
inst = apcWRInc
GOSUB SENDCOM
char = 85
GOSUB SENDDATA
inst = 224
GOSUB SENDCOM
char = 170
GOSUB SENDDATA
inst = 224
GOSUB SENDCOM
inst = 156
GOSUB SENDCOM
index = index + 1
GOTO XXXX
RETURN