KS0108 Module

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

johngb
Registered User
Registered User
Posts: 139
Joined: Tue Oct 03, 2006 10:16 pm

KS0108 Module

Post by johngb » Tue Sep 25, 2007 12:50 pm

Has the official FS0108 module ever been updated to support setting the RST line high?

I have had to use Octals excellent version which support 3 CS lines but also supports the RST option. It may have been updated but as I have been running beta versions of SF I may have missed a library update.

There doesn't seem to be a method of separately downloading the library.
JohnB

User avatar
octal
Registered User
Registered User
Posts: 586
Joined: Thu Jan 11, 2007 12:49 pm
Location: Paris IDF
Contact:

Post by octal » Wed Sep 26, 2007 10:13 am

Hi John.

Eric and myself only modified the official version of the ks0108 driver. We have not added RST support, it was already handled by the version we have.

Regards
Octal

johngb
Registered User
Registered User
Posts: 139
Joined: Tue Oct 03, 2006 10:16 pm

Post by johngb » Wed Sep 26, 2007 10:35 am

Which means I don't have the latest libraries - that's the trouble with being a beta tester.

Ahmed - Could you Email me the latest version (minus your mods) so I can keep the system Library up to date.

David - There ought to be a method of updating libraries independently to avoid this situation.

Also I noticed when running on my EasyPIC4 board that CS1 and CS2 are reversed. I.e. what purports to be CS1 actually selects the right hand part of the screen. So the option settings I needed where:

#Option GLCD_CS1 = PORTB.1
#Option GLCD_CS2 = PORTB.0

although the wiring on the board is actually the reverse (unless the CS ordering is supposed to run right to left).
JohnB

User avatar
octal
Registered User
Registered User
Posts: 586
Joined: Thu Jan 11, 2007 12:49 pm
Location: Paris IDF
Contact:

Post by octal » Wed Sep 26, 2007 10:45 am

johngb wrote:
Also I noticed when running on my EasyPIC4 board that CS1 and CS2 are reversed. I.e. what purports to be CS1 actually selects the right hand part of the screen. So the option settings I needed where:

#Option GLCD_CS1 = PORTB.1
#Option GLCD_CS2 = PORTB.0

although the wiring on the board is actually the reverse (unless the CS ordering is supposed to run right to left).
I also noticed that on my EasyPic4. Perhaps mikroE official GLCD that they sell with EasyPIC boards has a reveresed pinout :(

regards
Octal

iaing
Posts: 15
Joined: Fri Sep 28, 2007 12:36 pm
Location: Scotland

Post by iaing » Fri Sep 28, 2007 12:43 pm

This explains the problem I had when I was setting up the (very excellent) oshonsoft simulator to match the GLCD on the easyPic4 board!

I thought the problem had been with the simulator, now I know better! :D

I traced the tracks and lo' the mE GLCD does indeed have CS1 & CS2 reversed.

xor
Posts: 286
Joined: Sun Nov 05, 2006 1:15 pm
Location: NYC
Contact:

Post by xor » Tue Oct 02, 2007 2:13 am

The EasyPIC3 board shows CS1=PORTB.2 and CS2=PORTB.3 at the GLCD connector onboard. I could not get but half the KS0108 screen to show until I changed to GLCD_INVERT_CS=True and swapped the CS lines.

Has anyone figured if this is a hardware issue with the EasyPIC boards, or is it the type of GLCD? The datasheet for the GLCD for this board can be found here: http://www.xmocular.com/upload_img/2007110150439221.pdf

Thanks to this thread I was able to troubleshoot a non-working GLCD using SF on this board. Works great now with the following settings:

Code: Select all

#option GLCD_CS1 = PORTB.3       // chip select
#option GLCD_CS2 = PORTB.2       // chip select
#option GLCD_DATA = PORTD        // data port
#option GLCD_RS = PORTB.4        // RS pin
#option GLCD_EN = PORTB.6        // EN pin
#option GLCD_RW = PORTB.5        // RW pin
#option GLCD_RST = PORTB.7       // RST pin
#option GLCD_INVERT_CS = true    // invert CS lines...
#option GLCD_MODEL = KS0108      // GLCD driver
Last edited by xor on Sun Nov 16, 2008 11:54 pm, edited 1 time in total.

johngb
Registered User
Registered User
Posts: 139
Joined: Tue Oct 03, 2006 10:16 pm

Post by johngb » Tue Oct 02, 2007 8:16 am

Just to complete the picture, here are the config settings for the EasyPIC4 board.

Code: Select all

#Option GLCD_SCREEN_WIDTH = 128
#Option GLCD_SCREEN_HEIGHT = 64
#Option GLCD_DATA = PORTD
#Option GLCD_RS = PORTB.2
#Option GLCD_CS1 = PORTB.1
#Option GLCD_CS2 = PORTB.0
#Option GLCD_RW = PORTB.3
#Option GLCD_EN = PORTB.4
#Option GLCD_RST = PORTB.5
#Option GLCD_INIT_DELAY = 100
#option GLCD_INVERT_CS  = true 
JohnB

iaing
Posts: 15
Joined: Fri Sep 28, 2007 12:36 pm
Location: Scotland

Post by iaing » Tue Oct 02, 2007 12:36 pm

xor wrote:Has anyone figured if this is a hardware issue with the EasyPIC boards, or is it the type of GLCD?
I can only speak for the EasyPIC4 board and in that case the mapping shown on the silksreen is accurate (wrt /cs1 and /cs2) which implies that the glcd module has reversed mapping for these pins. However, if you check your datasheet, I don't believe you'll find anything that tells you which half of the screen /cs1 and /cs2 map to. It would be reasonable to assume the pins use a R->L mapping but maybe they mean from the back of the display :)

This brings up another subject. The fact that meBasic has closed libraries means you would never have realised that the mapping had been changed to cope with the module (I'm assuming you started using the EasyPIC with meBasic as I did). The SFB open libraries were a major consideration to me when I decided to ante-up and fork over my pennies for SFB.

Regards,

Iain

xor
Posts: 286
Joined: Sun Nov 05, 2006 1:15 pm
Location: NYC
Contact:

Post by xor » Tue Oct 02, 2007 1:58 pm

This will be useful information for the WIKI. I'm sure this problem will pop up again in discussions. I'll post this in FAQ... unless someone has objection.
Last edited by xor on Tue Oct 02, 2007 2:49 pm, edited 2 times in total.

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Tue Oct 02, 2007 2:41 pm

That sounds like a good idea. EasyPIC users might want to consider creating a module with these #options already set. Then, you just need to include the module in your program (before any other modules). For example,

Code: Select all

device = 18F452
clock = 20
include "EasyPICx.bas"
include "GLCD.bas"
or you could have a generic module, which configures itself based on a single option. For example,

Code: Select all

#option EasyPIC = 4
include "EasyPIC.bas"
include "GLCD.bas"

xor
Posts: 286
Joined: Sun Nov 05, 2006 1:15 pm
Location: NYC
Contact:

Post by xor » Tue Oct 02, 2007 2:49 pm

Dave,

Edits to the FAQ seem to be administrative. Is that correct... or is it me?

Those a great ideas for the #options.

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Tue Oct 02, 2007 2:56 pm

Sorry, yes - the FAQ is under Swordfish (rather than Swordfish User) which is admin only.

xor
Posts: 286
Joined: Sun Nov 05, 2006 1:15 pm
Location: NYC
Contact:

Post by xor » Wed Oct 03, 2007 5:57 pm

By the way, I'm getting some bad behavior out of my KS0108 with a 18F4550 @ 48MHz. I suppose that some of the timings are running a bit too fast. At 8MHz all is well all the time. Anyone else discover this type of problem with the library?

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Post by David Barker » Wed Oct 03, 2007 6:18 pm

I've just tried the 'GLCDFont.bas' sample, supplied with Swordfish, running on an 18F4550 @ 48MHz on a PROTON development board. It all looks OK. Do you have a small piece of code which shows the problem so I can test here? Also, are you running any USB code? - or are you just writing to the GLCD?

xor
Posts: 286
Joined: Sun Nov 05, 2006 1:15 pm
Location: NYC
Contact:

Post by xor » Wed Oct 03, 2007 6:43 pm

I'm not running USB. But after fiddling some more I am now beginning to suspect a problem with the EasyPIC3 programmer because I get a driver error message intermittently with the 18F4550 @48MHz....none @ 8MHz. I moved this PIC over to the EasyPIC4 and get a Vpp Voltage error almost all the time and a failed upload of hex. I may have jumped to the gun to suspect the library.

Here is the code:

Code: Select all

Device = 18F4550
Clock = 8

//set up config for 8MHz crystal and USB
//Config USBDIV = 2
//Config CPUDIV = OSC1_PLL2
//Config PLLDIV = 2
//Config FOSC   = HSPLL_HS

// EasyPIC3 GLCD Settings

#Option GLCD_SCREEN_WIDTH = 128  // screen pixels
#Option GLCD_SCREEN_HEIGHT = 64  // screen pixels
#option GLCD_DATA = PORTD        // data port
#option GLCD_CS1 = PORTB.3       // chip select
#option GLCD_CS2 = PORTB.2       // chip select
#option GLCD_RS = PORTB.4        // RS pin
#option GLCD_EN = PORTB.6        // EN pin
#option GLCD_RW = PORTB.5        // RW pin
#option GLCD_RST = PORTB.7       // RST pin
#Option GLCD_INIT_DELAY = 1000    // startup delay
#option GLCD_INVERT_CS = true    // invert CS lines...
#option GLCD_MODEL = KS0108      // GLCD driver

{
#Option GLCD_SCREEN_WIDTH = 128
#Option GLCD_SCREEN_HEIGHT = 64
#Option GLCD_DATA = PORTD
#Option GLCD_RS = PORTB.2
#Option GLCD_CS1 = PORTB.1
#Option GLCD_CS2 = PORTB.0
#Option GLCD_RW = PORTB.3
#Option GLCD_EN = PORTB.4
#Option GLCD_RST = PORTB.5
#Option GLCD_INIT_DELAY = 100
#option GLCD_INVERT_CS  = true
#option GLCD_MODEL = KS0108
}

Include "GLCD.bas"
Include "FixedFont.bas"


ADCON1 = 15
CMCON = 7
TRISB = 0
TRISD = 0
TRISE = 0

GLCD.Cls	
GLCD.SetFont(Fixed)
GLCD.Rectangle(0,0,128,22)
GLCD.Rectangle(1,1,127,21)
GLCD.WriteAt(4,4,"This Is Fixed Font")
GLCD.WriteAt(4,12,"This Is The Nxt Line")

Post Reply