Go Down

Topic: ST7565 GLCD Library Functions (Read 8794 times) previous topic - next topic

I still didn't have any luck with the u8glib, unfortunately.

Here's what I did:
1. Uncommented line 54 in HelloWorld.pde and changed the constructor to:
Code: [Select]
U8GLIB_LM6059 u8g(8, 9, 5, 7, 6);

2. Changed my Arduino pinouts accordingly

3. Uploaded the HelloWorld u8glib example program--nothing was displayed

4. Opened up the dogm128.h, changed lines 195-199 to:

Code: [Select]
#define PIN_RST   6
#define PIN_SCK   8
#define PIN_MOSI  9   
#define PIN_SS    5
#define PIN_A0_DEFAULT 7


5. Uploaded the GraphicTest dogm example program, which worked as expected.

Is this what you wanted me to test?  If not, just let me know what changes I should make and I'll give it another shot.

Also, I gather that the reset pin is simpler than I had originally thought--it just resets the display, and isn't a high-speed input or anything.  I did a bit of reading and it seems that you just have to make sure it's held at +3.3V and doesn't float.  Then, if grounded, it resets the display.  Is that correct?  I know it's a really simple question, but I hadn't looked it up.

olikraus

I am now thinking that still the init sequence is wrong --> PM

Reset: Yes, thats true. However, sometimes it is required to holde reset line low for some time.
This means: The power is already up at 3.3 Volt, but the reset line must still be at 0 Volt. So it can not be simply connected to the 3.3 Volt line. This may work only for some circuits.

Oliver

Quiggers

I'm having problems with the same display using an arduino mega 2560, also with a pic 16f88,
in both cases i'm assuming i have a error with my init sequence. I'm running the dogm128, screen which has the st7565 onboard. at 3.3v. I'll concentrate on the arduino here so ignore my pic comment.

i created a simple test sketch following the example init sequence on the data sheet provided with the gLCD.

Code: [Select]
#include <SPI.h>
//rs line is tied high to no need for pin assignment of rs.

const int A_Line = 49;
const int MISO   = 50;
const int MOSI   = 51;
const int SCK    = 52;
const int SS     = 53;

void setup()
    {
    pinMode(22,         INPUT);      //switch to decide if test command
    pinMode(A_Line,  OUTPUT);     //A0 line
    pinMode(MISO,  INPUT);      //not used
    pinMode(MOSI,  OUTPUT);     //connected to serial input of gLCD
    pinMode(SCK,    OUTPUT);     //clock
    pinMode(SS,    OUTPUT);    //chip select
   
    SPI.begin();                    //start spi protocol
    SPI.setDataMode(SPI_MODE0);      //set mode 0, L_to_h, no phase shift
    SPI.setBitOrder(MSBFIRST);      // send byte MSB to LSB
    SPI.setClockDivider(SPI_CLOCK_DIV64);    //divide system clock by 64 to give spi clock
    }
   
void loop()
    {
    long column= 0x0101;        // column address, 16 bit word
    screen_init();              // call init routine
    delay(2000);
    while(true)
        {
        if(digitalRead(22)==HIGH) 
            {
            screen_test();    //st7565 test case
            delay(1000);
            }
        else
            {
            screen_NOP();    // refresh
            delay(500);
            screen_write(0x44, 0xD0, column);    // write data, row, column
            delay(500);
            column++;                            //stop overwrites by incrementing address
            }
        }
    }
   
void screen_NOP(void)                            // NOP routine
    {
    digitalWrite(A_Line,  LOW);
    digitalWrite(SS,  LOW);
    SPI.transfer(0xE3);
    delay(1);
    digitalWrite(SS,  HIGH);
    digitalWrite(A_Line,  HIGH);
    }   
   
void screen_write(int letter, int page, long column)//write routine
    {
    int col_LSB, col_MSB;
    digitalWrite(A_Line,  LOW);
    digitalWrite(SS,  LOW);
    page=(page && 0x0F);
    page=(page || 0xB0);
    col_LSB = column;
    column = column >>8;
    col_MSB = column;
    SPI.transfer(page);
    delay(1);
    SPI.transfer(col_MSB);
    delay(1);
    SPI.transfer(col_LSB);
    delay(1);
    digitalWrite(SS,  HIGH);
    digitalWrite(A_Line,  HIGH);
    digitalWrite(SS,  LOW);
    SPI.transfer(letter);
    delay(1);
    digitalWrite(SS,  HIGH);
    }
   
void screen_init(void)
    {
    digitalWrite(A_Line, LOW);
    digitalWrite(SS,  LOW);       
    SPI.transfer(0x40);         //set display start address
    delay(1);
    SPI.transfer(0xA1);        //set view to 6oclock mode
    delay(1);
    SPI.transfer(0xC0);        //Common output mode
    delay(1);
    SPI.transfer(0xA6);        //Display normal
    delay(1);
    SPI.transfer(0xA2);        //gLCD bias
    delay(1);
    SPI.transfer(0x2F);        //Power conditioning
    delay(1);
    SPI.transfer(0xF8);        //Boost ratio MSB
    delay(1);
    SPI.transfer(0x00);        //Boost ratio LSB
    delay(1);
    SPI.transfer(0x27);        //Vreg set
    delay(1);
    SPI.transfer(0x81);        //contrast MSB
    delay(1);
    SPI.transfer(0x16);        //contrast LSB
    delay(1);
    SPI.transfer(0xAD);        //indicator on
    delay(1);
    SPI.transfer(0x01);        //indicator flash
    delay(500);
    SPI.transfer(0xAF);        //power on gLCD
    delay(1);
    digitalWrite(SS,  HIGH);
    digitalWrite(A_Line, HIGH);
    }

void screen_test(void)
  {
  digitalWrite(SS,     LOW);
  digitalWrite(A_Line, LOW);
  delay(1);
  SPI.transfer(0xF0);        //test script, not to be used in reg programme.
  delay(1);
  digitalWrite(SS,    HIGH);
  digitalWrite(A_Line,  HIGH);
  }
           

my gut tells me the screen_init(); isn't doing all its supposed to.
when i power the screen up nothing appears before the init seq or after yet if i connect the chip select line before power a Scottish tartan type pattern appears on the un-powered screen.

i'm hoping to use these screens for my final year project in uni but so far they have boogled my brains.

olikraus

At least for u8glib there is a fixed version for download.
See the init sequence for the there, which has been reported to be ok.
Not that the Adafruit ST7565 needs a different setup than the ST7565 inside the DOGM128.

Oliver

Quiggers

following adafruits init sequence, i've re-written the power controller commands and included a 50ms
delay between each step,
Code: [Select]
void screen_init(void)
    {
    digitalWrite(A_Line, LOW);
    digitalWrite(SS,  LOW);       
    SPI.transfer(0x40);         //set display start address
    delay(1);
    SPI.transfer(0xA1);        //set view to 6oclock mode
    delay(1);
    SPI.transfer(0xC0);        //Common output mode
    delay(1);
    SPI.transfer(0xA6);        //Display normal
    delay(1);
    SPI.transfer(0xA2);        //gLCD bias
    delay(1);

    SPI.transfer(0x2C); // Power condition
    delay(50);
    SPI.transfer(0x2E); //power condition
    delay(50);
    SPI.transfer(0x2F);        //Power conditioning
    delay(50);

    SPI.transfer(0xF8);        //Boost ratio MSB
    delay(1);
    SPI.transfer(0x00);        //Boost ratio LSB
    delay(1);
    SPI.transfer(0x27);        //Vreg set
    delay(1);
    SPI.transfer(0x81);        //contrast MSB
    delay(1);
    SPI.transfer(0x16);        //contrast LSB
    delay(1);
    SPI.transfer(0xAD);        //indicator on
    delay(1);
    SPI.transfer(0x01);        //indicator flash
    delay(50);
    SPI.transfer(0xAF);        //power on gLCD
    delay(1);
    digitalWrite(SS,  HIGH);
    digitalWrite(A_Line, HIGH);
    }

still no joy, i also noticed that the arduino seems to be floating the outputs, i'm using a resisitor devidor to step from 5v to 3.3v logic, but it seems to float at 2v. i know I2C uses external pull ups on the SDA and SCL lines but i have never seen it on SPI?

The spi doesnt seem to be doing the trick either as the v0 to v4 legs on the screen dont change their voltages after the boost and reg and control commands. I'm wondering is it a dead screen. the scotch tartan i mentioned previously makes me think it's alive but this is my first time working with a gLCD.

Without configuring the screen, did it display anything when you applied power to it? a cursor or test screen?

Thanks for the adafruit tip, their pdf was informative.

olikraus

Hi

What about this: You can use a lib which already supports the dogm128, e.g. the u8glib.
It would be easy to setup and check the dogm128 display with one of the examples.
Just install u8glib (unzip into libraries folder) and the examples are already part of the
Arduino IDE. (download u8glib from here: http://code.google.com/p/u8glib/downloads/list)

Then uncomment
//U8GLIB_DOGM128 u8g(13, 11, 10, 9);                    // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
and put your pin numbers into it:
U8GLIB_DOGM128 u8g(SCL, SDA, SS, A_Line);
Run the example and see if this works. If it does, then your wiring is ok.

You might also go to the u8glib sources and compare the init sequence.
http://code.google.com/p/u8glib/source/browse/csrc/u8g_dev_st7565_dogm128.c
The sequence starts at line 49

Then i would like to say, that the use of resistors is really unsafe. It is much better to use a level translating IC (e.g. 74HC4050). Also you should try to use ceramic caps for the display.

See some schematics here:
http://code.google.com/p/dogm128/wiki/dogm128_arduino_hardware

Oliver



Quiggers

i used the tantulum caps the datasheet specified.

i will try the tool kit above to see if the screen is alive or dead.

again thank you for your help.

StuC


This means, the constructor should be:
U8GLIB_LM6059(8, 9, 5, 7, 6)


Just to confirm, for anyone arriving here after a search (as I did), that the above constructor works correctly with the default pin assignments from the Adafruit tutorials for their ST7565, using the release 1.02 library.








PinAdafruit calls it...u8g calls it...
9Serial data out (SID)mosi: Serial data
8Serial clock out (SCLK)sck: Clock
7Data/Command select (RS or A0)a0: Data/instruction register select
6LCD reset (RST)reset: Display reset
5LCD chip select (CS)cs: Chip select


Cheers, Stu

A little Up for this post to give a feed back of experience with this Very Good Lib , that I think this is the one I'll choose for my project .

Hardware : Freeduino V1,22 / 128x64 LCD ST7565 / 4050 LEVEL SHIFTER
Lib : u8g_LM6059 [...] With this wire diagam : // SPI Com: SCK = 8, MOSI = 9, CS = 5, A0 = 7 , RST = 6

It Works Very Nice , but I have question about Image overlaping , clear LCD , and pages , that I put them in a new post because there is not the subject here :)



Go Up