Author Topic: SPI connection and initialization of NHD-C12864A1Z-FSW-FBW-HTT  (Read 2072 times)

nico

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Hello,
I have the display quoted on the title, and I would like to use it with an Arduino Uno (with an ATMega328).

I wrote a test program to switch on the whole display during 3 seconds and switch it off during 3 other seconds.
However, it doesn't work, and I need your help to understand why.

Here my code :

/* Pins definition
 *  Pin Arduino - function - Pin Newhaven screen
 * P10 - SS (SPI Bus Master Slave select) chip select - P6
 * P11 - MOSI (SPI Bus Master Output/Slave Input) - P2
 * P12 - MISO - None
 * P13 - Serial Clock MOSI - P1
 *
 * P9 - Reset : Operation Active LOW Reset signal - P5
 * P8 - A0 - Register Select. 0: instruction; 1: data - P4
 *
 * 3.3V - power supply - P3
 * GND - ground - P10
 * 5V and resistor 1 kohm - backlight LED - P11
 */

#define DATAOUT 11//MOSI
#define DATAIN  12//MISO
#define SPICLOCK  13//sck
#define SLAVESELECT 10//ss
#define RESET 9
#define A0 8

uint8_t display_on = 0b10101111;
uint8_t display_all_points = 0b10100101;
uint8_t shutdown_all_points = 0b10100100;
uint8_t n;

/* ======================================= Functions ================================================*/

void spi_transfer(volatile uint8_t data,volatile bool instruc_or_data) // char = int_8
{
  if (instruc_or_data) // instruction 0, data 1
  { digitalWrite(A0,HIGH); } // write data
  else
  { digitalWrite(A0,LOW); } // write instruction

  digitalWrite(SLAVESELECT,LOW); //enable device
 

  // writing a byte to the SPI Data Register SPDR starts the SPI clock generator
  SPDR = data;                    // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait for the end of the transmission
  {
    //write the data
  };                   // return the received byte
 
  Serial.print("Tranfer done \n");
  delay(500);
  digitalWrite(SLAVESELECT,HIGH); //disable device
}
/* ======================================== SETUP ===================================================*/

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600); //run the UART : serial monitor

  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK,OUTPUT);
  pinMode(SLAVESELECT,OUTPUT);
 
  digitalWrite(SLAVESELECT,LOW); //enable device
  digitalWrite(RESET,LOW); // reset active
  delay(1000); //wait 1 second
  digitalWrite(RESET,HIGH); //reset inactive
  digitalWrite(SLAVESELECT,HIGH); //disable device
                                     
  // We want SPCR = 01010000
  //interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
  //sample on leading edge of clk,system clock/4 rate (fastest)
  SPCR = (1<<SPE)|(1<<MSTR);

spi_transfer(display_on, 0);

 
}
/* ======================================= LOOP =====================================================*/

void loop() {
  // put your main code here, to run repeatedly:
  spi_transfer(display_all_points, 0);
  delay(3000);
  Serial.print("test \n");
  spi_transfer(shutdown_all_points, 0);
  delay(3000);
}


Thank you,
Nicolas
« Last Edit: April 27, 2016, 10:07:26 AM by nico »

Saurabh_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 355
  • Karma: 10
    • View Profile
Re: SPI connection and initialization of NHD-C12864A1Z-FSW-FBW-HTT
« Reply #1 on: April 28, 2016, 08:31:38 AM »
Hello Nico,

The Arduino Uno is a 5v MPU, can you confirm whether you are using a level shifter or if you have some protection built in so that you are not providing 5V to the rest of the display?

This display also would require an initialization sequence where you have to write certain registers before you are able to write to the display.
You can find a basic initialization sequence on page 8 of the datasheet for this display. (http://www.newhavendisplay.com/specs/NHD-C12864A1Z-FSW-FBW-HTT.pdf)

You can then use the following code to start writing to the display: http://www.newhavendisplay.com/app_notes/NHD-C12832A1Z.txt


 

NHD‐C12864A1Z‐FSW‐FBW‐HTT display clears after draw

Started by EdAverillBoard Graphic LCDs

Replies: 6
Views: 5683
Last post November 07, 2014, 08:25:20 AM
by Michael_L
Working on NHD‐2.4‐240320SF‐CTXL#‐FTN1, have problem in initialization

Started by sli25Board TFTs

Replies: 6
Views: 3776
Last post June 04, 2015, 09:52:25 PM
by sli25
NHD-C12864A1Z-FSRGB-FBW-HT1 boost speed (clear to black and black to clear)

Started by facotlBoard Graphic LCDs

Replies: 4
Views: 2592
Last post January 27, 2016, 10:18:45 AM
by facotl
Use of Timing characteristics in the initialization code of the display

Started by ShabdaBoard TFTs

Replies: 1
Views: 2922
Last post May 20, 2014, 08:00:39 AM
by Michael_L
Initialization code for M0220SD-202SDAR1 module??

Started by Javier OrtizBoard Vacuum Fluorescent Displays

Replies: 1
Views: 2512
Last post November 17, 2015, 05:12:51 PM
by Saurabh_B