ST7565 GLCD Support

Coding and general discussion relating to user created compiler modules

Moderators: David Barker, Jerry Messina

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

Re: ST7565 GLCD Support

Post by David Barker » Wed May 20, 2020 9:12 am

Apologies. I just looked at the controller datasheet. So that appears to leave three options:

(1) find a GLCD that utilises the parallel bus for the ST7565R or
(2) use a different (supported) Swordfish driver for a GLCD with parallel bus (KS0108 - tons of devices, well tested under swordfish) or
(3) implement SPI

raspen
Posts: 7
Joined: Thu Apr 30, 2020 2:28 pm

Re: ST7565 GLCD Support

Post by raspen » Fri May 22, 2020 3:28 pm

Thanks for everyone's help. I have had to move my project along so I am using DOGM163 with the ST7036 format.
I will check back regularly to see if anyone had as Parallel SPI written for DOG128W.

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

Re: ST7565 GLCD Support

Post by David Barker » Sat May 23, 2020 9:21 am

> I am using DOGM163

I have used these modules. They are very good. Let us know how you get on...

raspen
Posts: 7
Joined: Thu Apr 30, 2020 2:28 pm

Re: ST7565 GLCD Support

Post by raspen » Tue May 26, 2020 4:15 pm

Hi David,

Can you post a simple example using the DOGM163 showing your configuration and a simple "Hello Word" , " Line 2" , "Line 3"?
I am converting from PICBasic code, and getting hung up on include files and the configuration.

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

Re: ST7565 GLCD Support

Post by David Barker » Wed May 27, 2020 7:49 am

I don't have any tested code for Swordfish but I do have some Swordfish code which I ported over from Firewing (which 100% works) so it may work for you or at least get you started. I have attached the modules you need and here is a simple program which uses them. Pay particular attention to the options section - set for your hardware.

Code: Select all

// configure options...
#option LCD_DOGM = DOGM_163         // 3 line
#option LCD_INTERFACE = 4           // 4 bit data bus
#option LCD_BACKLIGHT = PORTB.6     // backlight pin
#option LCD_EN = PORTB.2            // EN
#option LCD_RS = PORTB.3            // RS
#option LCD_D0 = PORTC.3            // D0
#option LCD_D1 = PORTC.2            // D1
#option LCD_D2 = PORTC.1            // D2
#option LCD_D3 = PORTC.0            // D3

// import module
Include "LcdDogm.bas"

' clear LCD and set backlight        
Dogm.Cls()
Dogm.SetBacklight(1)

// write some data...
Dogm.WriteAt(1,1, "Line 1")
Dogm.WriteAt(2,1, "Line 2")
Dogm.WriteAt(3,1, "Line 3")
Attachments
Dogm.zip
(4.53 KiB) Downloaded 3 times

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

Re: ST7565 GLCD Support

Post by David Barker » Wed May 27, 2020 9:56 am

I have just tested the above code on real hardware and it works as expected (see image). For those people who have a Firewing board with LCD, here is the code I used:

Code: Select all

Device = 18F25K22
Clock = 64

// configure options...
#option LCD_DOGM = DOGM_163         // 3 line
#option LCD_INTERFACE = 4           // 4 bit data bus
#option LCD_BACKLIGHT = PORTB.6     // backlight pin 

#option LCD_RS = PORTB.4            // RS (D8)
#option LCD_EN = PORTA.2            // EN (D9)

#option LCD_D0 = PORTC.0            // D0
#option LCD_D1 = PORTC.1            // D1
#option LCD_D2 = PORTC.2            // D2
#option LCD_D3 = PORTB.5            // D3

// import module
Include "LcdDogm.bas"

' clear LCD and set backlight        
Dogm.Cls()
Dogm.SetBacklight(1)

// write some data...
Dogm.WriteAt(1,1, "Line 1")
Dogm.WriteAt(2,1, "Line 2")
Dogm.WriteAt(3,1, "Line 3")
Attachments
dogm_163.jpg
dogm_163.jpg (61.64 KiB) Viewed 59 times

raspen
Posts: 7
Joined: Thu Apr 30, 2020 2:28 pm

Re: ST7565 GLCD Support

Post by raspen » Wed May 27, 2020 2:27 pm

Thank you David,

Because I am running at 3.3 volts I changed Module LCDDogM initialize section to:

#if LCD_DOGM = DOGM_163
LCD.WriteCommand($29) ' 4 bit interface
LCD.WriteCommand($1C) ' bias set
LCD.WriteCommand($55) ''Power control + Contrast (HiByte)(for 5V=$52/3,3V=55)
LCD.WriteCommand($6D) ' Follower control (5V=$69/3,3V=6D)

And it works!

I also noted in the main program that D0 is actually D4...
#option LCD_RS = PORTB.4 // RS (D8) B.4
#option LCD_EN = PORTB.5 // EN (D9) B.5
#option LCD_D0 = PORTB.3 // D0 THIS IS D4
#option LCD_D1 = PORTB.2 // D1 THIS IS D5
#option LCD_D2 = PORTB.1 // D2 THIS IS D6
#option LCD_D3 = PORTB.0 // D3 THIS IS D7

I have a conference call with Display Visions to discuss how to rotate the screen 180 degrees. This will help with my board layout by moving all the pins to a better spot on my board. I will share the code to do this if possible.

Attached is an image of my board

Regards
Randy
Attachments
WORKS1.jpg
WORKS1.jpg (109.66 KiB) Viewed 57 times

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

Re: ST7565 GLCD Support

Post by Jerry Messina » Wed May 27, 2020 8:38 pm

David Barker wrote:
Wed May 27, 2020 7:49 am
I don't have any tested code for Swordfish but I do have some Swordfish code which I ported over from Firewing (which 100% works)...
That LCD module in your dogm.bas has the ability to map the LCD data pins anywhere you like. That's a nice feature!
I'm going to steal that code and put it into the standard swordfish LCD.bas library.

It's a touch slower, but what the heck, it's an LCD. Worth the tradeoff, esp with a 28-pin device where you might not have a whole port to dedicate.

I'll make it backwards compatible so you can use either the existing method to assign port pins (#option LCD_DATA = PORTD) or use the #option LCD_INTERFACE and set each pin.

Thanks!

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

Re: ST7565 GLCD Support

Post by David Barker » Thu May 28, 2020 7:56 am

Yes, I have found it useful in the past to do this on smaller devices ("spread" the data bus rather than use a contiguous set of pins on a single port). The speed really isn't an issue. An LCD refresh is slow enough that you won't see any difference. I've tested this in the past.

With respect to Randy's DOGM project. My top tip is to make sure you put the DOGM backlight on a hardware PWM pin. You can then dim or brighten the backlight, which is often essential in differing environmental conditions. You don't want to be doing this via software. Put it on a PWM pin to future proof your design (assuming you plan to use a backlight of course!).

As an aside, if you look at the "dogm.bas" support module you will see that it is virtually identical to the standard "LCD.bas" module with the exception of individual pin assignment. If you do make the changes Jerry, let me have a copy so I can test but it should work fine with standard LCD modules and the DOGM (although the DOGM does require a slightly modified interface like "LcdDogm" to support a different start up sequence, together with contrast and backlight support)

Post Reply