Hi, I am experiencing some difficulty with a 128 x 64 KS108 GLCD. I wonder if anyone can shed any light on this.
I am using an 18F452 clocked at 6MHz. I am using example code to test the display, but the results are rather random, usually only 1 side of the screen is displayed and this is badly corrupted. I know that the GLCD is working correctly because I have tried it with a dsPIC30F4013 and it is fine. The lead lengths to the LCD are short - around 5cm.
I have checked the data lines with a scope and it is apparent that the rise time of the signals is very bad, of the order of 200uS+. In my test code I have allowed the GLCD to initialize - this is where the poor rise times are observed. After the GLCD has started, I am toggling one of the GLCD data lines and another line; the rise time is excellent after the GLCD code has executed. I have tried placing the data port on portd as well as portb. There is no difference in behaviour.
Here is the code I am currently using:
Device = 18F452
Clock =6
#option GLCD_MODEL = KS0108 // GLCD driver
#option GLCD_DATA = PORTB
#option GLCD_RS = PORTC.1
#option GLCD_EN = PORTE.0
#option GLCD_RW = PORTC.0
#option GLCD_CS1 = PORTE.1
#option GLCD_CS2 = PORTE.2
#option GLCD_INVERT_CS = FALSE
#option GLCD_RST = PORTC.2
Include "GLCD.bas"
Include "utils.bas"
Include "FixedFont.bas"
SetAllDigital()
ADCON1 = $07 // PORTE as digital (GLCD)
TRISB = 0
TRISD = 0
TRISE = 0
DelayUS(100)
GLCD.Cls
GLCD.SetFont(Fixed)
GLCD.WriteAt(4,2,"System Font")
While true
LATB.7 =1
LATD.7 = 1
DelayUS(10)
LATD.7 = 0
LATB.7 =0
DelayUS(9)
Wend
End
It has been some time since I have used Swordfish, I am probably missing something. Any insights would be very welcome.
Thanks & very best regards.
KS108B GLCD Issue
Moderators: David Barker, Jerry Messina
You are using PortB as data port for your GLCD,
and you are also forcing in the same time TRISB = 0 (output only when it needs to be toggled by the GLCD module to read content of GLCD RAM, and worse, you are toggling LATB.7 =1 / LATB.7 =0 (witch is 8th bit of your data bit on GLCD).
Try to not use PortB (free it for the GLCD Module) and everything should be ok.
Code: Select all
GLCD_DATA = PORTB
Try to not use PortB (free it for the GLCD Module) and everything should be ok.
KS108B GLCD Issue
Thanks for your reply octal.
I changed some of the options:
#option GLCD_CS1 = PORTE.2
#option GLCD_CS2 = PORTE.1
#option GLCD_INVERT_CS = true
It now works perfectly.
Many thanks.
I changed some of the options:
#option GLCD_CS1 = PORTE.2
#option GLCD_CS2 = PORTE.1
#option GLCD_INVERT_CS = true
It now works perfectly.
Many thanks.