Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - sean

Pages: [1]
1
TFTs / Getting started with NHD-2.4-240320SF-CTXI#-FT1
« on: July 01, 2014, 04:02:50 PM »
I have not been able to get any response from the display to indicate that I am actually communicating with it.

I then write memory.
   LCD_CMD(0x29);// Turn on Display
   LCD_CMD(0x2C);// Memory Write
   for (mem=0; mem<38400; mem++)
   {
         //LCD_ARG(0x00);
         LCD_ARG(0x00);// Write in black
   }

I do not see any changes in the display.  I am using 8 bit communication.  I am not sure if I should be writing an upper byte in commands and/or data/parameters.

Here is the driver h files:

/*
 * Title: nwhvn24.h
 * Author: Sean O'Leary
 * Description: 2.4" Newhaven display with the
 *   ILI9341display driver.
 */

#ifndef __nwhvn24_h__
#define __nwhvn24_h__

// Size
#define LCD_HEIGHT 320
#define LCD_WIDTH 240

// Control bits.
#define LCD_BACKLIGHT_ON GPIO[(GPIO_PORTB + GPIO_OVRS) >> 2] = BL1
#define LCD_BACKLIGHT_OFF GPIO[(GPIO_PORTB + GPIO_OVRC) >> 2] = BL1

#define LCD_RD0 GPIO[(GPIO_PORTA + GPIO_OVRC) >> 2] = NH_RD
#define LCD_RD1 GPIO[(GPIO_PORTA + GPIO_OVRS) >> 2] = NH_RD

#define LCD_WR0 GPIO[(GPIO_PORTA + GPIO_OVRC) >> 2] = NH_WR
#define LCD_WR1 GPIO[(GPIO_PORTA + GPIO_OVRS) >> 2] = NH_WR

#define LCD_DC0 GPIO[(GPIO_PORTA + GPIO_OVRC) >> 2] = NH_DC
#define LCD_DC1 GPIO[(GPIO_PORTA + GPIO_OVRS) >> 2] = NH_DC

#define LCD_RESET0 GPIO[(GPIO_PORTB + GPIO_OVRC) >> 2] = NH_RST
#define LCD_RESET1 GPIO[(GPIO_PORTB + GPIO_OVRS) >> 2] = NH_RST

// This matches the DBx with the output pins
// clear bits first, then OR in the new data
#define LCD_DATA_SET(x) GPIO[(GPIO_PORTA + GPIO_OVR) >> 2] = \
    ((GPIO[(GPIO_PORTA + GPIO_PVR) >> 2] & 0xFFF807FF) | (x << 11))

void waitsome (void );
void init_lcd(void);
void LCD_CMD ( unsigned char cmd );
void LCD_ARG( unsigned char arg );
#endif


Here is the driver file:
/*
 * Title: nwhvn24.c
 * Author: Sean O'Leary
 * Description: Interface to the Newhaven 2.4" display.
 * Revision History: (Created Wed Mar  3 21:16:10 MST 2010)
 *   
 */

#include "config.h"
#include "nwhvn24.h"

// The color table value.
unsigned char RED, GREEN, BLUE;

void waitsome (void )
{
   extern unsigned char P;
   P=0;
   while (P<50);
 
}

void LCD_CMD ( unsigned char cmd )
{
  LCD_DC0;         // Command
  LCD_RD1;         // Command
  //LCD_WR0;
  //LCD_DATA_SET(0);   // High byte command index
  //LCD_WR1;         // Data latched on rising edge
  LCD_WR0;
  LCD_DATA_SET(cmd);      // Low byte command index
  LCD_WR1;         // Data latched on rising edge
     // (8080 parallel interface). Minimum data setup and hold time is
        // 10ns and 15ns respectively. Shouldn't need nop through 100 MHz
   // unless capacitance is high (>30pF) on data bus/control lines
  LCD_DC1;         // Default to argument/data
  wait();         
}

// Write byte argument (arg) to LCD controller
void LCD_ARG( unsigned char arg )
{
   // Assumes DC1, RD1 and CS0
  LCD_DC1;         // Argument/data
  //LCD_WR0;
  //LCD_DATA_SET(0);
  //LCD_WR1;
  LCD_WR0;
  LCD_DATA_SET(arg);
  LCD_WR1;
}


void init_lcd(void)
{
   putstring1("Initializing LCD\n");
  LCD_WR1;      // De-assert write
  LCD_RD1;
  LCD_WR0;
  LCD_RESET0;
  waitsome();
  LCD_RESET1;
  waitsome(); 
 
  // New routine
  LCD_CMD (0x28);   // Display OFF
 
  LCD_CMD(0x11);   // exit sleep mode
  LCD_ARG(0x00);   
 
  LCD_CMD(0xCB);   // Power Control A
  LCD_ARG(0x39);   // always 0x39
  LCD_ARG(0x2C);   // always 0x2C
  LCD_ARG(0x00);   // always 0x00
  LCD_ARG(0x34);   // Vcore=1.6V
  LCD_ARG(0x02);   // DDVDH=5.6V
 
  LCD_CMD(0xCF);   // Power Control B
  LCD_ARG(0x00);   // always 0x00
  LCD_ARG(0x81);   // PCEQ off
  LCD_ARG(0x30);   // ESD protection
 
  LCD_CMD(0xE8);   // Driver Timing Control A
  LCD_ARG(0x85);   // non-overlap
  LCD_ARG(0x01);   // EQ timing
  LCD_ARG(0x79);   // Pre-charge timing
   
  LCD_CMD(0xEA);   // Driver Timing Control B
  LCD_ARG(0x00);   // Gate driver timing
  LCD_ARG(0x00);   // always 0x00
   
  LCD_CMD(0xED);   // Power-ON sequence control
  LCD_ARG(0x64);   // soft start
  LCD_ARG(0x03);   // power on sequence
  LCD_ARG(0x12);   // power on sequence
  LCD_ARG(0x81);   // DDVDH enhance on
 
  LCD_CMD(0xF7);   // Pump ratio control
  LCD_ARG(0x20);   // DDVDH=2xVCI
 
  LCD_CMD(0xC0);   // Power control 1
  LCD_ARG(0x26);   //
   
  LCD_CMD(0xC1);   // Power control 2
  LCD_ARG(0x11);   //

  LCD_CMD(0xC5);   // VCOM control 1
  LCD_ARG(0x35);   //
  LCD_ARG(0x3E);   //

  LCD_CMD(0xC7);   // VCOM control 2
  LCD_ARG(0xBE);   //
 
  LCD_CMD(0x36);   // memory access control=BGR
  LCD_ARG(0x88);   //

  LCD_CMD(0xB1);   // Frame rate control
  LCD_ARG(0x00);   //
  LCD_ARG(0x10);   //

  LCD_CMD(0xB6);   // display function control
  LCD_ARG(0x0A);   //
  LCD_ARG(0xA2);   //

  LCD_CMD(0x3A);   // pixel format = 16 bit per pixel
  LCD_ARG(0x55);   //

  LCD_CMD(0xF2);   // 3G Gamma control
  LCD_ARG(0x02);   // off

  LCD_CMD(0x26);   // Gamma curve 3
  LCD_ARG(0x01);   //
 
  LCD_CMD(0xE0);   // Positive gamma correction
  LCD_ARG(0x1F);
  LCD_ARG(0x1B);
  LCD_ARG(0x18);
  LCD_ARG(0x0B);
  LCD_ARG(0x0F);
  LCD_ARG(0x09);
  LCD_ARG(0x46);
  LCD_ARG(0xB5);
  LCD_ARG(0x37);
  LCD_ARG(0x0A);
  LCD_ARG(0x0C);
  LCD_ARG(0x07);
  LCD_ARG(0x07);
  LCD_ARG(0x05);
  LCD_ARG(0x00);

  LCD_CMD(0xE1);   // Negative gamma correction
  LCD_ARG(0x00);
  LCD_ARG(0x24);
  LCD_ARG(0x27);
  LCD_ARG(0x04);
  LCD_ARG(0x10);
  LCD_ARG(0x06);
  LCD_ARG(0x39);
  LCD_ARG(0x74);
  LCD_ARG(0x48);
  LCD_ARG(0x05);
  LCD_ARG(0x13);
  LCD_ARG(0x38);
  LCD_ARG(0x38);
  LCD_ARG(0x3a);
  LCD_ARG(0x1F);

  LCD_CMD(0x2A);   // column address set
  LCD_ARG(0x00);   //
  LCD_ARG(0x00);   // start 0x0000
  LCD_ARG(0x00);   //
  LCD_ARG(0xEF);   // end 0x00EF (240)

  LCD_CMD(0x2B);   // page address set
  LCD_ARG(0x00);   //
  LCD_ARG(0x00);   // start 0x0000
  LCD_ARG(0x01);   //
  LCD_ARG(0x3F);   // end 0x013F (320)
 
}

I would appreciate any suggestions.

Pages: [1]