Problem with CLS in KS0108 driver

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
blackcattech
Posts: 113
Joined: Mon Jan 11, 2010 10:39 pm
Location: Chesterfield

Problem with CLS in KS0108 driver

Post by blackcattech » Sun Jan 17, 2010 7:24 pm

I'm trying to use a 128x64 LCD which uses the KS0108 driver. I can get graphics and text to display correctly. However, the GLCD.cls command does not work. The screen is 'garbled' - it looks like the command is in effect doing nothing and the data is just what happened at power-on.

Does anyone have any suggestions what may be wrong?

This LCD has a reset line which is connected. I think the driver toggles this automatically? I'm not sure however whether the hardware reset should clear the data RAM though.

I've tried this both with the 'standard' KS0108 driver and the version on here for the 3 CS devices (even though this only has 2 CS lines)

Also, I am using this with a touchscreen and I've been trying the code for this, adapted to suit. This code uses the GLCD.fill command but this does not seem to be supported on the KS0108 - any ideas why not?

blackcattech
Posts: 113
Joined: Mon Jan 11, 2010 10:39 pm
Location: Chesterfield

Post by blackcattech » Sun Jan 17, 2010 7:27 pm

Forgot to add - I'm using SF V 2.1.0.2 and a PIC18F2520

blackcattech
Posts: 113
Joined: Mon Jan 11, 2010 10:39 pm
Location: Chesterfield

Post by blackcattech » Sun Jan 17, 2010 8:40 pm

More info: I can confirm that GLCD.cls is being called and the compiler is using the version in my UserLibrary folder. I've modified KS0108 as below and this clears the screen, albeit slowly!

Pen.Color = 0
y = 0
Repeat
x = 0
Repeat
SetPixel(x,y)
Inc(x)
Until x > (GLCDWidth-1)
Inc(y)
Until y > (GLCDHeight-1)

rmteo
Posts: 237
Joined: Fri Feb 29, 2008 7:02 pm
Location: Colorado, USA

Post by rmteo » Sun Jan 17, 2010 10:13 pm

I use GLCD.Cls all the time with the KS0108 driver without problems. Your GLCD definition should look something like this:

Code: Select all

#option GLCD_DATA = PORTB        ' data port
#option GLCD_RS = PORTA.1        ' RS pin
#option GLCD_EN = PORTA.0        ' EN pin
#option GLCD_RW = PORTA.2        ' RW pin
#option GLCD_CS1 = PORTA.5       ' chip select
#option GLCD_CS2 = PORTA.4       ' chip select
#option GLCD_RST = PORTA.3
#option GLCD_ASPECT_RATIO = 100      
#option GLCD_INIT_DELAY = 0  

blackcattech
Posts: 113
Joined: Mon Jan 11, 2010 10:39 pm
Location: Chesterfield

Post by blackcattech » Mon Jan 18, 2010 11:20 pm

Yup, got all the defines set up - I would paste this below but Swordfish isn't letting me copy at the moment....

As I say, drawing lines and printing text works fine and if I clear the screen one pixel at a time that works fine also, it is the CLS routine itself which doesn't seem to function.

blackcattech
Posts: 113
Joined: Mon Jan 11, 2010 10:39 pm
Location: Chesterfield

Post by blackcattech » Mon Jan 18, 2010 11:27 pm

Sorted the copy and paste - I had an online survey open in another tab and they block the copy function, presumably for security. GLCD options are below:

Code: Select all

#option GLCD_MODEL = KS0108        // GLCD driver    
#option GLCD_DATA = PORTB        // data port
#option GLCD_RS = PORTC.1        // RS pin
#option GLCD_EN = PORTA.6        // EN pin
#option GLCD_RW = PORTC.0        // RW pin
#option GLCD_CS1 = PORTA.5       // chip select
#option GLCD_CS2 = PORTA.4       // chip select
#option GLCD_ASPECT_RATIO = 75   // aspect ratio
#option GLCD_INIT_DELAY = 100    // initialisation delay (ms)
#option GLCD_INVERT_CS = false   // invert CS lines... 
#option GLCD_RST = PORTA.7       // RST select

Post Reply