GLCD KS0108 issue

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

xva3rjy
Posts: 40
Joined: Sat Sep 27, 2014 11:41 am

GLCD KS0108 issue

Post by xva3rjy » Sun Oct 19, 2014 4:05 pm

I've been having a issue that cannot figure out.

CODE 1 and PHOTO 1 ..works and all 3 areas of the display work.
CODE 2 and PHOTO 2 ..not working...area 3 (far right) nothing is displayed.

I'd appreciate any suggestions.

CODE 1

Code: Select all

Device = 18F2525
Clock =   10                          //external crystal

//Config OSC = INTIO67                // configure OSC for internal

// User options
#Option GLCD_MODEL = KS0108         // GLCD driver   
#option GLCD_SCREEN_WIDTH = 192     // Screen Width in Pixels
#option GLCD_SCREEN_HEIGHT = 64     // Screen Height in Pixels
#Option GLCD_DATA = PORTB           // data port
#Option GLCD_RS  = PORTA.3          // RS pin
#Option GLCD_RW  = PORTA.2          // RW pin
#Option GLCD_EN  = PORTA.1          // EN pin
#Option GLCD_CS1 = PORTA.4          // chip select
#Option GLCD_CS2 = PORTA.5          // chip select
#Option GLCD_CS3 = PORTC.6          //chip select
#Option GLCD_RST = PORTA.0          // reset pin
#Option GLCD_ASPECT_RATIO = 100     // aspect ratio, smaller number will squeeze y for GLCD circles and box
#Option GLCD_INIT_DELAY = 50        // initialisation delay (ms)
//#Option GLCD_INVERT_CS = true       // invert CS lines...
 
// Modules
Include "glcd.bas"           // main GLCD module
Include "graphics.bas"       // support for GLCD
Include "Bitmaps.bas"        // support for GLCD
Include "utils.bas"          // support to make all MCU pins Digital
Include "Arial.bas"          // ArialFont for GLCD

// PORT setup and PLL Multiplier (set internal Osc to 32Mhz)     
//TRISA = %00000000               //
//TRISB = %00000000               // Set all Ports output
//TRISC = %00000000               //
//OSCCON = %01111100              // Set up the internal oscillator for 8Mhz
//OSCCON = %01110000              // Set up the internal oscillator for 16mHz
//OSCTUNE.6 = 1                   // Frequency Multiplier PLL for INTOSC Enable bit (Enabled)            

SetAllDigital                 // set MCU pins as digital

// Demo pattern on GLCD
GLCD.Rectangle(0,0,191,63)  // draws a rectangle on all corners of display (X,Y,X,Y)
GLCD.Line(6,6,20,60)        // draws line (left of screen)
GLCD.Line(180,2,105,2)      // draws line (top right of screen)
GLCD.Ellipse(40,32,20,30)   // draws Ellipse
GLCD.Circle(160,32,20)       // draws Circle
   
GLCD.SetFont(ArialBold)   // set font BOLD
GLCD.WriteAt(80,25,"TEST 1 2 3 4")  
GLCD.WriteAt(100,50,"TEST 1 2 3 4")
GLCD.SetImage(65,4,BatteryImage, cmXOR)  
GLCD.SetImage(150,4,BtnOK, cmXOR)
GLCD.SetImage(120,35,BtnCancel, cmXOR)
CODE 2

Code: Select all

Device = 18F2525
Clock =   10                        // external crystal

//Config OSC = INTIO67                // configure OSC for internal

// User options
#Option GLCD_MODEL = KS0108         // GLCD driver   
#option GLCD_SCREEN_WIDTH = 192     // Screen Width in Pixels
#option GLCD_SCREEN_HEIGHT = 64     // Screen Height in Pixels
#Option GLCD_DATA = PORTB           // data port
#Option GLCD_RS  = PORTA.3          // RS pin
#Option GLCD_RW  = PORTA.2          // RW pin
#Option GLCD_EN  = PORTA.1          // EN pin
#Option GLCD_CS1 = PORTA.4          // chip select
#Option GLCD_CS2 = PORTA.5          // chip select
#Option GLCD_CS3 = PORTC.6          //chip select
#Option GLCD_RST = PORTA.0          // reset pin
#Option GLCD_ASPECT_RATIO = 100     // aspect ratio, smaller number will squeeze y for GLCD circles and box
#Option GLCD_INIT_DELAY = 50        // initialisation delay (ms)
//#Option GLCD_INVERT_CS = true       // invert CS lines...

// Modules
Include "glcd.bas"           // main GLCD module
Include "graphics.bas"       // support for GLCD
Include "Bitmaps.bas"        // support for GLCD
Include "utils.bas"          // support to make all MCU pins Digital
Include "Arial.bas"          // Arial font for GLCD
Include "FixedFont.bas"      // Fixed font for GLCD
Include "Garamond.bas"       // Garamond font for GLCD
Include "Tahoma.bas"         // Tahoma font for GLCD
Include "Verdana.bas"        // Verdanal font for GLCD
Include "Times.bas"          // Times font for GLCD
Include "DS1307.bas" 
Include "convert.bas"
Include "ISRRX.bas"
Include "usart.bas"
Include "math.bas"

Dim location As Byte
Dim msgb0 As Byte
Dim msgb1 As Byte
Dim w As Word
Dim fwdpwr As Byte
Dim revpwr As Byte
Dim vswr As Byte
Dim vswr1 As Byte
Dim vswr2 As Byte

// PORT setup and PLL Multiplier (set internal Osc to 32Mhz)     
//TRISA = %00000000               //
//TRISB = %00000000               // Set all Ports output
//TRISC = %00000000               //
//OSCCON = %01111100              // Set up the internal oscillator for 8Mhz
//OSCCON = %01110000              // Set up the internal oscillator for 16mHz
//OSCTUNE.6 = 1                   // Frequency Multiplier PLL for INTOSC Enable bit (Enabled)            

ADCON1 = $07 // PORTE as digital (GLCD)
SetAllDigital()
//SetAllDigital                   // ?? set MCU pins as digital
GLCD.Cls
 
GLCD.SetFont(ArialBold)         // set font BOLD
GLCD.Rectangle(0,0,191,63)      //good..set to maximum size

USART.SetBaudrate(br19200)
ISRRX.Initialize()   

While (true)
    // check for usart overrun. it'll stop data if not cleared
    If (ISRRX.Overrun) Then
        ISRRX.Reset()
    EndIf     

    // to receive a message from the PICAXE you must always read three bytes
    // get first byte (location index)
    While (ISRRX.DataAvailable = false)
    End While
    location = ISRRX.ReadByte()

    // get second byte - lowbyte of parameter (LSB)
    While (ISRRX.DataAvailable = false)
    End While
    msgb0 = ISRRX.ReadByte()

    // get third byte - highbyte of parameter (MSB)
    While (ISRRX.DataAvailable = false)
    End While
    msgb1 = ISRRX.ReadByte()

    Select (location)
        Case 23         //hserout 0,(23,"PT") 
            GLCD.WriteAt(5, 5, msgb0, msgb1)
        Case 24         //hserout 0,(24,"T ")  
            GLCD.WriteAt(20, 5, msgb0, msgb1)
        Case 25         //hserout 0,(25," E")
            GLCD.WriteAt(35, 5, msgb0, msgb1)
        Case 26         //hserout 0,(26,"RR") 
            GLCD.WriteAt(50, 5, msgb0, msgb1)       
        Case 17         //hserout 0,(17,Statusb0,Statusb1)  
            GLCD.WriteAt(5, 15, DecToStr(msgb0), DecToStr(msgb1))
        Case 18         //hserout 0,(18,FWDPWRb0,FWDPWRb1)
            GLCD.WriteAt(5, 25, "FWD PWR = ",DecToStr(msgb0))
            fwdpwr=msgb0
        Case 19         //hserout 0,(19,REVPWRb0,REVPWRb1)
            GLCD.WriteAt(5, 35, "REV PWR = ",DecToStr(msgb0))
            revpwr=msgb0
            vswr1=1+sqrt(fwdpwr/revpwr)
            vswr2=1-sqrt(fwdpwr/revpwr)
            vswr=vswr1/vswr2
            GLCD.WriteAt(100,5,DecToStr(vswr))
        Case 20         //hserout 0,(20,TEMPb0,Tempb1)
            GLCD.WriteAt(5, 45, "TEMP = ",DecToStr(msgb0/2))
        Case 21         //hserout 0,(21,VOLTAGEb0,VOLTAGEb1)
            GLCD.WriteAt(100,5,"Case 21 = ",DecToStr(msgb0), DecToStr(msgb1))
        Case 22         //hserout 0,(22,CURRENTb0,CURRENTb1)
            GLCD.WriteAt(100,20, "Case 22 = ",DecToStr(msgb0), DecToStr(msgb1))
        Else            // parameter is binary data...
         // write data as two bytes (LSB, MSB)
         GLCD.WriteAt(100,35, "ELSE 2 bytes= ",DecToStr(msgb0), ", ", DecToStr(msgb1))
         // or write data as a single 16-bit value
         w.byte1 = msgb1
         w.byte0 = msgb0
         GLCD.WriteAt(100,50, "ELSE 16-bit value = ", DecToStr(w))
    End Select
End While
Attachments
PHOTO 2.JPG
PHOTO 2.JPG (19.97 KiB) Viewed 5679 times
PHOTO 1.JPG
PHOTO 1.JPG (21.99 KiB) Viewed 5679 times

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: GLCD KS0108 issue

Post by Coccoliso » Mon Oct 20, 2014 7:20 am

Hello,
clearly you are using the module with 3 CS (KS0108.BAS modified by Eric Couratier, Ahmed Lazreg) copied into UserLibrary right ? not the original SF by David.
The module with 3 CS needs the #option GLCD_CS_COUNT = 3 to set correctly the third CS.
I see that the first GLCD.Rectangle (0,0,191,63) is done properly, after the includes PORTC.6 as overrides.. Usart hardware use this pin, choose another port for CS3
Last edited by Coccoliso on Mon Oct 20, 2014 9:03 am, edited 1 time in total.

xva3rjy
Posts: 40
Joined: Sat Sep 27, 2014 11:41 am

Re: GLCD KS0108 issue

Post by xva3rjy » Mon Oct 20, 2014 8:59 am

Test 1 - modified the following

//Include "DS1307.bas"

Result - no change - nothing displayed in far right of GLCD

------------------------------------------------------------

Test 2 - modified the following

#option DS1307_SI2C = true
#option I2C_SCL = PORTC.3
#option I2C_SDA = PORTC.4
...
Include "DS1307.bas"

Result - no change - nothing displayed in far right of GLCD

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: GLCD KS0108 issue

Post by Coccoliso » Mon Oct 20, 2014 9:11 am

Sorry.. Portc.6 is used by hw usart as TX line.. Choose another port pin for CS3.

xva3rjy
Posts: 40
Joined: Sat Sep 27, 2014 11:41 am

Re: GLCD KS0108 issue

Post by xva3rjy » Mon Oct 20, 2014 9:20 am

I have no other free pins. Is there a away to disable the hw usart TX line?

xva3rjy
Posts: 40
Joined: Sat Sep 27, 2014 11:41 am

Re: GLCD KS0108 issue

Post by xva3rjy » Mon Oct 20, 2014 9:50 am

I new to this, however when reviewing the 18f2525 manual, I noticed you can override the ports.

Does any know how I can disable PortC.6 as the usart TX pin so that I can use it as CS3 GLCD pin?

Jerry Messina
Swordfish Developer
Posts: 1245
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: GLCD KS0108 issue

Post by Jerry Messina » Mon Oct 20, 2014 10:39 am

Actually I don't think you can on that chip. Once you enable the uart it takes over the pins.

Since you're not really using the uart TX, maybe you could try swapping C6 with the GLCD_RST on A0.
Once you enable the uart the TX will idle high which should be fine as long as the RST is active low.

If you actually want to use it as a RST, disable the uart, twiddle C6, and then reenable the uart.

xva3rjy
Posts: 40
Joined: Sat Sep 27, 2014 11:41 am

Re: GLCD KS0108 issue

Post by xva3rjy » Mon Oct 20, 2014 10:51 am

I also found [UMCUserCodeIOPins]
however can't figure out how to configure it.

http://www.sfcompiler.co.uk/wiki/pmwiki ... CodeIOPins

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: GLCD KS0108 issue

Post by Coccoliso » Mon Oct 20, 2014 11:04 am

Are ASM commands then must called inside an

Code: Select all

Asm-
...
End Asm
structure but as you see this piece of code is valid for 18FxxKnn pics and 18F1220/1230. From datasheet of MCU you can see if there is some else for your pic type. See page 98 of MC datasheet.

Jerry Messina
Swordfish Developer
Posts: 1245
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: GLCD KS0108 issue

Post by Jerry Messina » Mon Oct 20, 2014 11:47 am

I also found [UMCUserCodeIOPins]
That's basically the same stuff that's in SetAllDigital() as long as you have the latest updates.

You might try disabling the uart TXEN and see if that works.
AFTER the call to usart.setbaudrate() try

Code: Select all

TXSTA.bits(5) = 0     // disable TXEN
output(PORTC.6)      // make sure pin is output

// try to set output pin
high(PORTC.6)
low(PORTC.6)


xva3rjy
Posts: 40
Joined: Sat Sep 27, 2014 11:41 am

Re: GLCD KS0108 issue

Post by xva3rjy » Mon Oct 20, 2014 1:01 pm

Jerry, As per suggestion Iedited part of the code (see below), however as per attached photo I'm still having the same issue.

USART.SetBaudrate(br19200)

TXSTA.bits(5) = 0 // disable TXEN
output(PORTC.6) // make sure pin is output
// try to set output pin
high(PORTC.6)
low(PORTC.6)

ISRRX.Initialize()
Attachments
PHOTO3.JPG
PHOTO3.JPG (22.37 KiB) Viewed 5636 times

Jerry Messina
Swordfish Developer
Posts: 1245
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: GLCD KS0108 issue

Post by Jerry Messina » Mon Oct 20, 2014 2:00 pm

Try re-arranging the code so that the uart gets setup first

Code: Select all

SetAllDigital()

// setup uart
USART.SetBaudrate(br19200)
// make uart TX pin IO
TXSTA.bits(5) = 0     // disable TXEN
output(PORTC.6)      // make sure pin is output

ISRRX.Initialize()   

// setup glcd
GLCD.Cls
GLCD.SetFont(ArialBold)         // set font BOLD
GLCD.Rectangle(0,0,191,63)      //good..set to maximum size
I haven't actually tried this with a real chip, but if you CAN disable the tx pin and still leave the RX working that's how you'd do it

Also, did you add '#option GLCD_CS_COUNT = 3'
The module with 3 CS needs the #option GLCD_CS_COUNT = 3 to set correctly the third CS
You'll have to eventually trim down some of your WriteAt statements. I think the strings are too long for where you're putting them.

xva3rjy
Posts: 40
Joined: Sat Sep 27, 2014 11:41 am

Re: GLCD KS0108 issue

Post by xva3rjy » Mon Oct 20, 2014 3:49 pm

I revised the code, however it did not work. Also the box outline is not being displayed on the right.

SetAllDigital() // set MCU pins as digital

// setup uart
USART.SetBaudrate(br19200)
// make uart TX pin IO
TXSTA.bits(5) = 0 // disable TXEN
Output(PORTC.6) // make sure pin is output
GLCD.Cls

ISRRX.Initialize()

ADCON1 = $07 // PORTE as digital (GLCD)
// setup glcd
GLCD.Cls
GLCD.SetFont(Fixed) // set font BOLD
GLCD.Rectangle(0,0,191,63) //good..set to maximum size
Attachments
PHOTO4.JPG
PHOTO4.JPG (19.58 KiB) Viewed 5632 times

Jerry Messina
Swordfish Developer
Posts: 1245
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: GLCD KS0108 issue

Post by Jerry Messina » Mon Oct 20, 2014 4:52 pm

The line

Code: Select all

ADCON1 = $07 // PORTE as digital (GLCD)
is incorrect for your chip, so remove it. The 18F2525 digital IO is taken care of by SetAllDigital().

The next step is to make sure that GLCD will function correctly when the uart isn't initialized.
Comment out the call to USART.SetBaudrate() for the time being.

Try with C6 output high:

Code: Select all

SetAllDigital() // set MCU pins as digital

// setup uart
'USART.SetBaudrate(br19200)
// make uart TX pin IO
'TXSTA.bits(5) = 0 // disable TXEN
high(PORTC.6) // make sure pin is output high

GLCD.Cls()
GLCD.SetFont(Fixed) // set font BOLD
GLCD.Rectangle(0,0,191,63) //good..set to maximum size
Try with C6 output low:

Code: Select all

SetAllDigital() // set MCU pins as digital

// setup uart
'USART.SetBaudrate(br19200)
// make uart TX pin IO
'TXSTA.bits(5) = 0 // disable TXEN
low(PORTC.6) // make sure pin is output low

GLCD.Cls()
GLCD.SetFont(Fixed) // set font BOLD
GLCD.Rectangle(0,0,191,63) //good..set to maximum size
See if either of those work.

xva3rjy
Posts: 40
Joined: Sat Sep 27, 2014 11:41 am

Re: GLCD KS0108 issue

Post by xva3rjy » Mon Oct 20, 2014 6:05 pm

Both gave the same result and did not work.
The outline worked with both, however when the baudrate and TXTSTA line lines were enabled, the right side display did not work including the outline.

Post Reply