Pages: [1]   Go Down
Author Topic: LCD Driver Issues  (Read 739 times)
0 Members and 1 Guest are viewing this topic.
BC, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 8
To fail or not to fail
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've been working with an Arduino Uno for a few months and now I have an Embedded Artists’ 3.2 inch QVGA TFT Color LCD Board I'm trying to get working with the Arduino.  Been struggling with it the last week with no progress.

I've read on the forums about the touch LCD screen Arduino shield using the same driver, but I wasn't able to see the pinout for the files.  So I've been trying just to turn the LCD on and writing to the register properly.  At first, I tried it with SPI

Code:
/*
Pin settings
SPI Pins
Pin 10 = SS/CS   //slave select or Chip Select
Pin 11 = MOSI    // Master Out Slave In
Pin 12 = MISO    // Master In Slave Out
Pin 13 = SCK     //System Clock, used to sync pulses

Pin 9 = RS // Register Set input: low for Commands and high for GRAM


*/


#include <SPI.h>

//PINS
const int RS = 9;     //Active low commands or Active high for ram writing
const int CS = 10;    //chip select/slave select for LCD
const int MOSI = 11;  //Master Out Slave In
const int MISO = 12;  // Master In Slave Out
const int SCK  = 13;  //Serial Clock, used to sync pulses
int i = 0;
byte responseOne = 0;
byte responseTwo = 0;

void setup(){
  Serial.begin(9600);
  //initiate SPI pins
  SPI.begin();
  //start shifting with MSB MSB (bit 7, bit 6, etc)
  SPI.setBitOrder(MSBFIRST);
  //samples on rise, idle low
  SPI.setDataMode(SPI_MODE1);
  //set SPI speed to 8 MHz
  SPI.setClockDivider(SPI_CLOCK_DIV2);
 
  //set pin modes
  pinMode(RS, OUTPUT);
 
  delay(30);
 
  //initialize the LCD
  LCD_Reset();
  Serial.println('Initialization complete\n');
}

void loop(){
  delay(500);
  Serial.print('Round:');
  Serial.println(i);
  //set the cursor position
  WriteToLCD(0x004E,i);
  WriteToLCD(0x004F,i);
 
  //set pixel color
  WriteToLCD(0x0022,0xF0F0);
 
  i++;
 
}

void WriteToLCD(word address, word value){
  //move to command address
  digitalWrite(RS,LOW);            //instruction to accept ram position
  digitalWrite(CS,LOW);            //activate LCD for serial transmission
  byte temp = highByte(address);  //takes the leftmost byte of 'address'
  responseOne = SPI.transfer(temp);             //sends the value via SPI
  temp = lowByte(address);        //takes the rightmost byte of 'address'
  responseTwo = SPI.transfer(temp);             //sends the value via SPI
  digitalWrite(CS,HIGH);           //deactivate LCD for serial transmission
  Serial.print("Address: ");
  Serial.print(address,HEX);
  Serial.print(" Response: ");
  Serial.print(responseOne,HEX);
  Serial.print(" ");
  Serial.print(responseTwo,HEX);
 
  //enter in command
  digitalWrite(RS,HIGH);   //instruction to enter command
  digitalWrite(CS,LOW);    //activate LCD for serial transmission
  temp = highByte(value); //takes the leftmost byte of 'value'
  responseOne = SPI.transfer(temp);     //sends the value via SPI
  temp = lowByte(value);  //takes the rightmost byte of 'value'
  responseTwo = SPI.transfer(temp);     //sends the value via SPI
  digitalWrite(CS,HIGH);   //deactivate LCD for serial transmission
  Serial.print("           Command: ");
  Serial.print(value,HEX);
  Serial.print(" Response: ");
  Serial.print(responseOne,HEX);
  Serial.print(" ");
  Serial.println(responseTwo,HEX);
}

void LCD_Reset(void)
{
  WriteToLCD(0x0007, 0x0021);   // Display Control
// D1 0x0000 = display off
// D1 0x0002 = display on
// D0 0x0000 = internal display halt
// D0 0x0001 = internal display operate     
  WriteToLCD(0x0000, 0x0001);   //Start Oscillation OSCEN=1
WriteToLCD(0x0007, 0x0023);   // Display Control   
  WriteToLCD(0x0010, 0x0000);   //Sleep mode cancel
 
        delay(30);
 
  WriteToLCD(0x0007, 0x0033);   // Display Control   
  WriteToLCD(0x0011, 0x6030);   //Entry Mode
                                    // DFM   0x4000 = 262k color
                                    // DFM   0x6000 = 65k color
                                    // AM    0x0000 = horizontal display
                                    // AM    0x0008 = Vertical display
                                    // ID[0] 0x0000 = horizontal decrement
                                    // ID[0] 0x0010 = horizontal increment
                                    // ID[1] 0x0000 = Vertical decrement
                                    // ID[1] 0x0020 = Vertical increment
  WriteToLCD(0x0002, 0x0000);   //LCD driver AC setting
        WriteToLCD(0x0022, 0x0000);  //write to ram
}

I couldn't confirm if my registry edits were bad or if my writing to the GRam is faulty.  I moved over trying parallel but I can't even get the LCD to turn on.

* 3.2_inch_QVGA_TFT_Color_LCD_Users_Guide-Version_2.1_Rev_A.pdf (436.5 KB - downloaded 16 times.)
* 3.2TFT_IC-SSD1289.pdf (859.17 KB - downloaded 13 times.)
Logged

Pages: [1]   Go Up
Jump to: