NHD-2.8-25664UMB3 SPI INTERFACE HELP

Comments

7 comments

  • Michael_L

    We have plenty of example code available to get you started with your software development.  One document you can refer to is on our example program code webpage for that display, here: https://newhavendisplay.com/content/app_notes/OLED_25664.txt 

     Some more example code I have for the Arduino Mega is included below:

    //---------------------------------------------------------
    /*
    NHD_2_8_25664_mega.ino
    Program for writing to Newhaven Display 256x64 graphic OLED with SSD1322 controller (serial mode)

    (c)2014 Mike LaVine - Newhaven Display International, LLC.

            This program is free software; you can redistribute it and/or modify
            it under the terms of the GNU General Public License as published by
            the Free Software Foundation; either version 2 of the License, or
            (at your option) any later version.

            This program is distributed in the hope that it will be useful,
            but WITHOUT ANY WARRANTY; without even the implied warranty of
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
            GNU General Public License for more details.
    */
    //---------------------------------------------------------


    int RS = 30;      // RS (D/C) signal connected to Arduino digital pin 30 (can be tied low for 3-wire SPI)
    int RW = 31;      // /WR (R/W) signal connected to Arduino digital pin 31 (can be tied low)
    int E = 32;      // /RD (E) signal connected to Arduino digital pin 32  (can be tied low)
    int RES = 33;     // /RES signal connected to Arduino digital pin 33 
    int CS = 34;     // /CS signal conencted to Arduino digital pin 34
    int SCLK = 22;   // SCLK signal connected to Arduino digital pin 22
    int SDIN = 23;   // SDIN signal connected to Arduino digital pin 23

    void comm_out(unsigned char c)
    {
      unsigned char i;
      digitalWrite(CS, LOW);
      digitalWrite(SDIN, LOW);
      digitalWrite(SCLK, LOW);
      digitalWrite(SCLK, HIGH);
      for(i=0;i<8;i++)
      {
        digitalWrite(SCLK, LOW);
        if((c&0x80)>>7==1)
        {
          digitalWrite(SDIN, HIGH);
        }
        else
        {
          digitalWrite(SDIN, LOW);
        }
        c = c << 1;
        digitalWrite(SCLK, HIGH);
      }
      digitalWrite(CS, HIGH);
    }

    void data_out(unsigned char d)
    {
      unsigned char i;
      digitalWrite(CS, LOW);
      digitalWrite(SDIN, HIGH);
      digitalWrite(SCLK, LOW);
      digitalWrite(SCLK, HIGH);
      for(i=0;i<8;i++)
      {
        digitalWrite(SCLK, LOW);
        if((d&0x80)>>7==1)
        {
          digitalWrite(SDIN, HIGH);
        }
        else
        {
          digitalWrite(SDIN, LOW);
        }
        d = d << 1;
        digitalWrite(SCLK, HIGH);
      }
      digitalWrite(CS, HIGH);
    }

    void Checkerboard_25664()
    {
            unsigned int i, j;

    Set_Column_Address_25664(0x00,0x77);
    Set_Row_Address_25664(0x00,0x7F);
    Set_Write_RAM_25664();

    for(i=0;i<64;i++)
    {
    for(j=0;j<120;j++)
    {
    data_out(0xF0);
    data_out(0xF0);
    }
    for(j=0;j<120;j++)
    {
    data_out(0x0F);
    data_out(0x0F);
    }
    }
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------

    void Set_Column_Address_25664(unsigned char a, unsigned char b)
    {
    comm_out(0x15); // Set Column Address
    data_out(a); //   Default => 0x00
    data_out(b); //   Default => 0x77
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------

    void Set_Row_Address_25664(unsigned char a, unsigned char b)
    {
    comm_out(0x75); // Set Row Address
    data_out(a); //   Default => 0x00
    data_out(b); //   Default => 0x7F
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------

    void Set_Write_RAM_25664()
    {
    comm_out(0x5C); // Enable MCU to Write into RAM
    }
    //--------------------------------------------------------------------------
    //--------------------------------------------------------------------------

    void setup()
    {
      DDRC = 0xFF;         //set PORTC of Arduino (control signals) as output
      DDRA = 0xFF;         //set PORTA of Arduino (data signals) as output
      PORTA = 0x03;        //set DB7-DB2 to LOW, and DB1-DB0 to HIGH
      digitalWrite(RS, LOW);
      digitalWrite(RW, LOW);
      digitalWrite(E, LOW);
      digitalWrite(RES, HIGH);
      delay(1000);
     
      comm_out(0xFD);
      data_out(0x12);
     
      comm_out(0xB3);
      data_out(0xD0);
      comm_out(0xCA);
      data_out(0x3F);
      comm_out(0xA2);
      data_out(0x00);
      comm_out(0xA1);
      data_out(0x00);
      comm_out(0xA0);
      data_out(0x14);
      data_out(0x11);
      comm_out(0xB5);
      data_out(0x00);
      comm_out(0xAB);
      data_out(0x01);
      comm_out(0xB4);
      data_out(0xA0);
      data_out(0xB5);
      comm_out(0xC1);
      data_out(0x7F);
      comm_out(0xC7);
      data_out(0x0F);
      comm_out(0xB9);
      comm_out(0xB1);
      data_out(0xE2);
      comm_out(0xD1);
      data_out(0xA2);
      data_out(0x20);
      comm_out(0xBB);
      data_out(0x1F);
      comm_out(0xB6);
      data_out(0x08);
      comm_out(0xBE);
      data_out(0x07);
      comm_out(0xA6);
      comm_out(0xA9);
      comm_out(0xAF);
      delay(10);
    }

    void loop()
    {
      Checkerboard_25664();
      delay(1000);
    }
    0
  • asifjahmed

    Hello -

    I also am having difficulties in getting this display to work. I've tried on both a beaglebone black and an Arduino Mega. On the beaglebone black, I follow your recommended init sequence, and all i get is a random matrix-like grayscale display. On the mega (using the exact code above), I get nothing at all. The display is simply blank. Please advise, as I am working on product development and didn't anticipate so much difficulty with the display.

    0
  • riaz

    I’ve had a similar problem with parallel interface (6800), which may be due to me not controlling CS line (lack of i/o pins made me tie that pin  permanently LOW and RES High, this i will verify soon ). i found the command instructions worked fine but data instruction had a problem.

    try issuing  command(0xA4) and command(0xA5) and see what happens.


    I’m currently using 4 wire spi interface, which works fine.  i will return back to parallel just as soon as i have sorted out other aspects of my project.

    0
  • asifjahmed

    Can you share your 4-wire SPI code? I am not interested in parallel, only SPI. If I can at least just verify that the display is working (get something readable) then that will at least give me some motivation. At this point I just cannot get any human-readable text on the screen. In contrast, I have a couple of SSD1306-based displays, and I have that one working on both the beaglebone and the arduino over 4-wire SPI. HELP!

    0
  • asifjahmed

    Here is my wiring for the Mega. Mike - I am using your code straight from this thread. When wired up as 4-wire SPI (as in picture) I get absolutely nothing. If I put BS0 high (3-wire mode) I at least get a flicker on the display when the arduino boots (and this can be repeated by resetting arduino). But that's as far as I can get currently... My SSD1306 display works fine on both devices (beaglebone and arduino). Please advise!!!

    0
  • Michael_L

    The code I have posted here has been tested and verified to work.  You mentioned you used this initialization on the beaglebone and you got a random matrix-like grayscale screen.  This is normal, as it is simply the random "garbage" present in the display's RAM at start up.  You would need to proceed to write to it to see desired results.
    If this initialization is working for you with the beaglebone, but not the Arduino, the problem must not be the display or code.  On the Arduino Mega, have you replaced the voltage regulator with a 3.3V regulator to supply the display with 3.3V logic?  Is your SPI speed for whatever reason too fast on the Arduino?

    0
  • Engineering Support
    Community moderator

    Hi piratecb,

    please see our code for NHD-2.8-25664UC -with Arduino

    For further assistance, please reach out to us at nhtech@newhavendisplay.com

     

    0

Please sign in to leave a comment.