Bayside888
Member
I am having trouble representing numbers (decimal, integers). For example, I am using some older code by Hippy to bit-bang data to an LCD. The code is:
Code:
Symbol bitRS = bit8
Symbol bitWR = bit9
Symbol bitE = bit10
Symbol bitD4 = bit12
Symbol bitD5 = bit13
Symbol bitD6 = bit14
Symbol bitD7 = bit15
symbol bit_light=bit11 ; transistor that controls LCD backlight:
Pause 2000
Initialisation:
HI2cSetup I2CMASTER, $4E, I2CSLOW, I2CBYTE
b0 = $33 : Gosub SendB0AsInitByte
b0 = $33 : Gosub SendB0AsInitByte
b0 = $32 : Gosub SendB0AsInitByte
b0 = $28 : Gosub SendB0AsCommandByte
b0 = $0C : Gosub SendB0AsCommandByte
b0 = $06 : Gosub SendB0AsCommandByte
b0 = $01 : Gosub SendB0AsCommandByte
Pause 2
SendLCD:
b0 = $80 : Gosub SendB0AsCommandByte
b0 = "M" : Gosub SendB0AsDataByte
b0 = "o" : Gosub SendB0AsDataByte
b0 = "n" : Gosub SendB0AsDataByte
b0 = "i" : Gosub SendB0AsDataByte
b0 = "t" : Gosub SendB0AsDataByte
b0 = "o" : Gosub SendB0AsDataByte
b0 = "r" : Gosub SendB0AsDataByte
b0 = " " : Gosub SendB0AsDataByte
b0 = "O" : Gosub SendB0AsDataByte
b0 = "N" : Gosub SendB0AsDataByte
Send_Count:
b0 = $01 : Gosub SendB0AsCommandByte ;go home
counter=0
do while counter<9
pause 500
b0 = $counter : Gosub SendB0AsDataByte
inc counter
loop
SendB0AsInitByte:
Pause 15
bitWR = 0 ; Keep WR signal low
SendB0AsCommandByte:
bitRS = 0 ; Send byte as a command
SendB0AsDataByte:
bitD4 = bit4 ; Send msb first
bitD5 = bit5
bitD6 = bit6
bitD7 = bit7
bit_light=1 ;LCD backlight on
bitE = 1
b2 = b1 ; b2 holds msb with E set
bitE = 0 ; b1 holds msb with E clear
HI2cOut b1, ( b2, b1 )
bitD4 = bit0 ; Send lsb second
bitD5 = bit1
bitD6 = bit2
bitD7 = bit3
bitE = 1
b2 = b1 ; b2 holds lsb with E set
bitE = 0 ; b1 holds lsb with E clear
HI2cOut b1, ( b2, b1 )
bitRS = 1 ; Send data byte next time
Return
End Code
So, I want to calculate a number and display it on the LCD. The problem is in the "Send_Count" segment. I tried setting several formats, just squares on the LCD.
Thanks
Code:
Symbol bitRS = bit8
Symbol bitWR = bit9
Symbol bitE = bit10
Symbol bitD4 = bit12
Symbol bitD5 = bit13
Symbol bitD6 = bit14
Symbol bitD7 = bit15
symbol bit_light=bit11 ; transistor that controls LCD backlight:
Pause 2000
Initialisation:
HI2cSetup I2CMASTER, $4E, I2CSLOW, I2CBYTE
b0 = $33 : Gosub SendB0AsInitByte
b0 = $33 : Gosub SendB0AsInitByte
b0 = $32 : Gosub SendB0AsInitByte
b0 = $28 : Gosub SendB0AsCommandByte
b0 = $0C : Gosub SendB0AsCommandByte
b0 = $06 : Gosub SendB0AsCommandByte
b0 = $01 : Gosub SendB0AsCommandByte
Pause 2
SendLCD:
b0 = $80 : Gosub SendB0AsCommandByte
b0 = "M" : Gosub SendB0AsDataByte
b0 = "o" : Gosub SendB0AsDataByte
b0 = "n" : Gosub SendB0AsDataByte
b0 = "i" : Gosub SendB0AsDataByte
b0 = "t" : Gosub SendB0AsDataByte
b0 = "o" : Gosub SendB0AsDataByte
b0 = "r" : Gosub SendB0AsDataByte
b0 = " " : Gosub SendB0AsDataByte
b0 = "O" : Gosub SendB0AsDataByte
b0 = "N" : Gosub SendB0AsDataByte
Send_Count:
b0 = $01 : Gosub SendB0AsCommandByte ;go home
counter=0
do while counter<9
pause 500
b0 = $counter : Gosub SendB0AsDataByte
inc counter
loop
SendB0AsInitByte:
Pause 15
bitWR = 0 ; Keep WR signal low
SendB0AsCommandByte:
bitRS = 0 ; Send byte as a command
SendB0AsDataByte:
bitD4 = bit4 ; Send msb first
bitD5 = bit5
bitD6 = bit6
bitD7 = bit7
bit_light=1 ;LCD backlight on
bitE = 1
b2 = b1 ; b2 holds msb with E set
bitE = 0 ; b1 holds msb with E clear
HI2cOut b1, ( b2, b1 )
bitD4 = bit0 ; Send lsb second
bitD5 = bit1
bitD6 = bit2
bitD7 = bit3
bitE = 1
b2 = b1 ; b2 holds lsb with E set
bitE = 0 ; b1 holds lsb with E clear
HI2cOut b1, ( b2, b1 )
bitRS = 1 ; Send data byte next time
Return
End Code
So, I want to calculate a number and display it on the LCD. The problem is in the "Send_Count" segment. I tried setting several formats, just squares on the LCD.
Thanks