Author Topic: NHD-2.8-25664UMB3 SPI INTERFACE HELP  (Read 8241 times)

piratecb

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
NHD-2.8-25664UMB3 SPI INTERFACE HELP
« on: May 29, 2014, 12:03:48 AM »
HELLO EVERYBODY, Y RECENTLY BOUGHT A NHD-2.8-25664UMB3 DISPLAY FOR AN ELECTRONIC DEVICE I'M WORKING ON BUT I LACK OF EXPERIENCE IN ELECTRONICS DESIGN PLEASE HELP ME WITH THIS: ROTARY ENCODER+SSD1322+SPI 4 WIRE INTERFACE = MENU SCROLLING ON THE DISPLAY...THANKS IN ADVANCE..ANY HELP WILL BE APPRECIATED!

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: NHD-2.8-25664UMB3 SPI INTERFACE HELP
« Reply #1 on: May 29, 2014, 11:47:59 AM »
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: http://www.newhavendisplay.com/app_notes/OLED_25664.txt.  Some more example code I have for the Arduino Mega is included below:

Code: [Select]
//---------------------------------------------------------
/*
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);
}

asifjahmed

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: NHD-2.8-25664UMB3 SPI INTERFACE HELP
« Reply #2 on: September 14, 2014, 10:39:26 AM »
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.

riaz

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
    • View Profile
Re: NHD-2.8-25664UMB3 SPI INTERFACE HELP
« Reply #3 on: September 15, 2014, 04:02:52 AM »
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.

asifjahmed

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: NHD-2.8-25664UMB3 SPI INTERFACE HELP
« Reply #4 on: September 15, 2014, 07:31:02 AM »
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!

asifjahmed

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: NHD-2.8-25664UMB3 SPI INTERFACE HELP
« Reply #5 on: September 15, 2014, 08:28:21 AM »
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!!!


Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: NHD-2.8-25664UMB3 SPI INTERFACE HELP
« Reply #6 on: September 16, 2014, 09:40:25 AM »
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?

 

NHD‐0420CW‐AB3 I2C Interface

Started by andersonpdBoard OLEDs

Replies: 1
Views: 2634
Last post January 23, 2015, 10:00:06 AM
by Michael_L
NHD‐0420DZW‐AY5 SPI Interface

Started by vinaykBoard OLEDs

Replies: 0
Views: 2048
Last post October 26, 2015, 05:13:10 AM
by vinayk
NHD-2.4-240320CF-CTXI#-FT (ST7789S controller) and STM32F4 FSMC LCD Interface

Started by deshayesBoard TFTs

Replies: 1
Views: 2666
Last post March 17, 2016, 06:25:18 PM
by fahad
7.0" TFTs with capacitive Touch and 8080 interface availability?

Started by gdoraisaBoard TFTs

Replies: 1
Views: 1219
Last post June 30, 2016, 07:54:11 AM
by Saurabh_B
A graphical user interface for Atmels SAM4S Xplained Pro.

Started by PaulVdBerghBoard Customer Projects

Replies: 1
Views: 3226
Last post April 01, 2015, 01:28:00 PM
by Bridgette_E