# Serial Graphical Display driver 2013-09-08

Ok.... Jason Lopez has prompted me to stick this here so others may use / follow..

I have been toying with a small 128x64 serial graphical display... The chipset is the ST7565 and they are cheap and readily avalable...

Adafruit sells them by the truck load.... Namely for the Arduino market...

SO!! I have been writing a driver for the humble pic.... This will run on the pic16f877a as there is just enough memory to create the 1k buffer that I create for blitting, but if you spend the same amount of money on a pic18f2620, you'll have tons of memory and code space..

INCIDENTALLY!!! Anyone who needs to make large tables or requires a huge linear buffer can use this information.

Jason had written an excellent starter driver for the famous Noia7110 screen... This uses the SED1565 driver, which is completely compatible ( bias changes only, but this is well documented ) AND the KS0713... This is virtually the same chip... There is another Novatek NT7534... This is EXACTLY the same as the Systech ST7565...

Ok, that said, off we go.. ISIS has the model "HDG12864F-1" which uses the sed1565 controller so anyone who uses ISIS can jump straight in...

First you create the project in MPLAB IDE. I still use Version 8.83 so X users will need to modify to use that... I also use C18.. I may create the project in MPLAB X with the XC8 compiler, but not yet.

Once you have created your project you need to grab the linker script from the LKR directory.. There are LOTS of them but I selected this one "18f2620.lkr" as this is the chip I chose. You need to place a copy in your working directory... Once the file is in your directory attach it to your project... To do this right click the "Linker script" folder in the project window... Select "Add files" in the context menu that appears... Navigate to YOUR project directory and select the newly copied linker script..

Now to edit to suit our needs..

Under the DATABANK section you will see 15 data banks named gpr0 to gpr15 all of these are 255 bytes in size I edited this section at gpr5 to look like this

Code:
DATABANK   NAME=gpr4       START=0x400          END=0x4FF
DATABANK   NAME=big        START=0x500          END=0x8FF			PROTECTED
DATABANK   NAME=gpr9       START=0x900          END=0x9FF
Notice that I renamed the bank from "gpr5 to "big" AND changed the pages to "PROTECTED"
Notice also that I have merged 5,6,7 and 8 togther to form a 1k space... 0x500 throu 0x8FF is 0x3FF or 1024 bytes..

You don't need to rename the banks but now you can see what I have done...
Next we need to identify the section so we can get to it.

This is done in the SECTION part at the bottom..
DO NOT EDIT THE STACK SECTION or you will suffer.

Code:
SECTION    NAME=CONFIG     ROM=config
SECTION    NAME=buffer_scn RAM=big

STACK SIZE=0x100 RAM=gpr14
I have identified my 1k data bank as "buffer_scn".. You can call it what you want.. Also its associated with RAM.. UDATA to be exact..

Once this is done we can now access one complete linear section of RAM...

As this new piece of RAM is in UDATA ( uninitialized data ) we need a pragma so the linker can find it.

At the top of your C file that requires the buffer you place this small amount of code..
C:
// Back buffer for the display
#pragma udata buffer_scn			// This must be set up
static char buffer[1024];			// in the linker script
#pragma udata					// As pages are only 255 bytes
// You need 4 pages I used 0x500 - 0x800
Now you can use the buffer as a large array to hold a copy of the screen and "double buffer" the screen..

Here is my lowlevel screen tools.. "lowlevel.c"

The two fonts that Jason provided... "fonts.c"

And a sample logo bitmap.. "logo.c"

The screens can be made in LCDAsistant readily available on t'net.. I include it here aswell...

And there you have it a simple complete LCD driver for all those chipsets...

Enjoy...

P.S. one other little detail.... Your main () should initialize the OpenSPI() function..
• 8.1 KB Views: 610
• 835 bytes Views: 595
• 11.8 KB Views: 763
• 6.3 KB Views: 560
• 433.7 KB Views: 535
Author
Ian Rogers
Views
2,860
First release
Last update
Rating
0 ratings