Author Topic: [TFT][NHD-2.4-240320CF-CTXI-F][MSP] Interface  (Read 2238 times)

RAMESHCHAND

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
[TFT][NHD-2.4-240320CF-CTXI-F][MSP] Interface
« on: October 05, 2015, 12:22:36 AM »
Hi,
i'm trying to interface NHD-2.4-240320CF-CTXI-F display with msp430 controller. i want to initialize LCD i'm using below mentioned code to initialize and LCD display is attached to this post.
i'm new to this. My question is how i can know that LCD  initialized properly ?

#define LCD_RES            GPIO_PIN3       //P1.3      OUTPUT
#define LCD_RD            GPIO_PIN0       //PJ0        OUTPUT
#define LCD_WR            GPIO_PIN1       //PJ1        OUTPUT
#define LCD_D_C            GPIO_PIN2       //PJ2        OUTPUT
#define LCD_CS            GPIO_PIN3       //PJ3        OUTPUT
/*
 * TFT_LCD.c
 *
 *  Created on: 02-Oct-2015
 *   
 */

//---------------------------------------------------------
/*
(c)2014 Curt Lagerstam - 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.
*/
//---------------------------------------------------------

/*******************************************************************************
* Function Name  : TFT_24_7789_Init
* Description    : Initializes LCD with built-in ST7789S controller.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
#include <driverlib.h>
#include "Pinmap.h"
#include "TFT_LCD.h"
void GPIO_ResetBits(unsigned int ui_Port, unsigned int ui_Port_Pin)
{
   GPIO_setOutputLowOnPin( ui_Port, ui_Port_Pin );

}

void GPIO_SetBits(unsigned int ui_Port, unsigned int ui_Port_Pin)
{
   GPIO_setOutputHighOnPin( ui_Port, ui_Port_Pin );
   
}

void GPIO_Write(unsigned char ui_Port, unsigned int ui_data)
{
   PBOUT = (PBOUT & 0x00)|ui_data;
}
void TFT_delay(unsigned int x)
{
   unsigned int i;
   for (i = 0; i<= x; i++)
   {
      _delay_cycles(1000);
   }
}
void TFT_24_7789_Init(void)
{

   GPIO_ResetBits(GPIO_PORT_PJ, LCD_CS);
   GPIO_SetBits(GPIO_PORT_PJ, LCD_RD);
   GPIO_ResetBits(GPIO_PORT_PJ, LCD_WR);
   GPIO_ResetBits(GPIO_PORT_P1, LCD_RES);
   TFT_delay(100);
   GPIO_SetBits(GPIO_PORT_P1, LCD_RES);
   TFT_delay(100);
   TFT_24_7789_Write_Command(0x11);//exit SLEEP mode
   TFT_delay(100);

   TFT_24_7789_Write_Command(0x36);
   TFT_24_7789_Write_Data(0x80);//MADCTL: memory data access control

   TFT_24_7789_Write_Command(0x003A);
   TFT_24_7789_Write_Data(0x0066);//COLMOD: Interface Pixel format *** I use 262K-colors in 18bit/pixel format when using 8-bit interface to allow 3-bytes per pixel

   //TFT_24_7789_Write_Command(0x003A);TFT_24_7789_Write_Data(0x0055);//COLMOD: Interface Pixel format  *** I use 65K-colors in 16bit/pixel (5-6-5) format when using 16-bit interface to allow 1-byte per pixel

   TFT_24_7789_Write_Command(0x00B2);
   TFT_24_7789_Write_Data(0x000C);
   TFT_24_7789_Write_Data(0x0C);
   TFT_24_7789_Write_Data(0x00);
   TFT_24_7789_Write_Data(0x33);
   TFT_24_7789_Write_Data(0x33);//PORCTRK: Porch setting

   TFT_24_7789_Write_Command(0x00B7);
   TFT_24_7789_Write_Data(0x0035);//GCTRL: Gate Control

   TFT_24_7789_Write_Command(0x00BB);
   TFT_24_7789_Write_Data(0x002B);//VCOMS: VCOM setting

   TFT_24_7789_Write_Command(0x00C0);
   TFT_24_7789_Write_Data(0x002C);//LCMCTRL: LCM Control

   TFT_24_7789_Write_Command(0x00C2);
   TFT_24_7789_Write_Data(0x0001);
   TFT_24_7789_Write_Data(0xFF);//VDVVRHEN: VDV and VRH Command Enable

   TFT_24_7789_Write_Command(0x00C3);
   TFT_24_7789_Write_Data(0x0011);//VRHS: VRH Set

   TFT_24_7789_Write_Command(0x00C4);
   TFT_24_7789_Write_Data(0x0020);//VDVS: VDV Set

   TFT_24_7789_Write_Command(0x00C6);
   TFT_24_7789_Write_Data(0x000F);//FRCTRL2: Frame Rate control in normal mode

   TFT_24_7789_Write_Command(0x00D0);
   TFT_24_7789_Write_Data(0x00A4);
   TFT_24_7789_Write_Data(0xA1);//PWCTRL1: Power Control 1

   TFT_24_7789_Write_Command(0x00E0);
   TFT_24_7789_Write_Data(0x00D0);
   TFT_24_7789_Write_Data(0x0000);
   TFT_24_7789_Write_Data(0x0005);
   TFT_24_7789_Write_Data(0x000E);
   TFT_24_7789_Write_Data(0x0015);
   TFT_24_7789_Write_Data(0x000D);
   TFT_24_7789_Write_Data(0x0037);
   TFT_24_7789_Write_Data(0x0043);
   TFT_24_7789_Write_Data(0x0047);
   TFT_24_7789_Write_Data(0x0009);
   TFT_24_7789_Write_Data(0x0015);
   TFT_24_7789_Write_Data(0x0012);
   TFT_24_7789_Write_Data(0x0016);
   TFT_24_7789_Write_Data(0x0019);//PVGAMCTRL: Positive Voltage Gamma control

   TFT_24_7789_Write_Command(0x00E1);
   TFT_24_7789_Write_Data(0x00D0);
   TFT_24_7789_Write_Data(0x0000);
   TFT_24_7789_Write_Data(0x0005);
   TFT_24_7789_Write_Data(0x000D);
   TFT_24_7789_Write_Data(0x000C);
   TFT_24_7789_Write_Data(0x0006);
   TFT_24_7789_Write_Data(0x002D);
   TFT_24_7789_Write_Data(0x0044);
   TFT_24_7789_Write_Data(0x0040);
   TFT_24_7789_Write_Data(0x000E);
   TFT_24_7789_Write_Data(0x001C);
   TFT_24_7789_Write_Data(0x0018);
   TFT_24_7789_Write_Data(0x0016);
   TFT_24_7789_Write_Data(0x0019);//NVGAMCTRL: Negative Voltage Gamma control

   TFT_24_7789_Write_Command(0x002A);
   TFT_24_7789_Write_Data(0x0000);
   TFT_24_7789_Write_Data(0x0000);
   TFT_24_7789_Write_Data(0x0000);
   TFT_24_7789_Write_Data(0x00EF);//X address set

   TFT_24_7789_Write_Command(0x002B);
   TFT_24_7789_Write_Data(0x0000);
   TFT_24_7789_Write_Data(0x0000);
   TFT_24_7789_Write_Data(0x0001);
   TFT_24_7789_Write_Data(0x003F);//Y address set

   TFT_delay(10);
}




/*******************************************************************************
* Function Name  : TFT_24_7789_Write_Command
* Description    : writes a 1 byte command to 2.4" TFT.
* Input          : command = one byte command (register address)
* Output         : None
* Return         : None
*******************************************************************************/
void TFT_24_7789_Write_Command(unsigned int command)
{
   GPIO_ResetBits(GPIO_PORT_PJ, LCD_CS);
   GPIO_ResetBits(GPIO_PORT_PJ, LCD_D_C);
   GPIO_SetBits(GPIO_PORT_PJ, LCD_RD);
   GPIO_ResetBits(GPIO_PORT_PJ, LCD_WR);
   GPIO_Write(GPIO_PORT_PB, command);
   TFT_delay(10);
   GPIO_SetBits(GPIO_PORT_PJ, LCD_WR);
   TFT_delay(1);
}

/*******************************************************************************
* Function Name  : TFT_24_7789_Write_Data
* Description    : writes 1 byte of data to 2.4" TFT.
* Input          : data1 = one byte of display data or command parameter
* Output         : None
* Return         : None
*******************************************************************************/
void TFT_24_7789_Write_Data(unsigned int data1)
{
   GPIO_Write(GPIO_PORT_PB, data1);
   GPIO_SetBits(GPIO_PORT_PJ, LCD_D_C);
   GPIO_ResetBits(GPIO_PORT_PJ, LCD_WR);
   TFT_delay(1);
   GPIO_SetBits(GPIO_PORT_PJ, LCD_WR);
}

/*******************************************************************************
* Function Name  : TFT_24_7789_demo
* Description    : NHD-2.4-240320CF-CTXI# interface.
* Input          : None
* Output         : None
* Return         : 1-end of function reached
*******************************************************************************/
int TFT_24_7789_demo(void)
{
//   GPIO_SetBits(GPIOC, IM0);      //8-bit mode
   TFT_24_7789_Init();
         TFT_24_7789_Write_Command(0x0029);            //display ON

return 1;
}



void main (void)
{
   int i=0;
    WDTCTL = WDTPW + WDTHOLD;   // Stop watchdog timer
    P1DIR |= (BCKLT_PWM + LED_PWR + LED_BKL);                         //Output
    PJDIR |= (LCD_RD + LCD_WR + LCD_D_C + LCD_CS);                   //Output
    P3DIR |= (LCD_DB8 + LCD_DB9 + LCD_DB10 + LCD_DB11 + LCD_DB12 + LCD_DB13 + LCD_DB14 + LCD_DB15);                   //Output

    TFT_24_7789_demo();
   while(1)
   {
      P1OUT |= BCKLT_PWM;
      P1OUT |= LED_PWR;
      P1OUT |= LED_BKL;
      TFT_24_7789_Write_Command(0x2A);            // Column Address
      TFT_24_7789_Write_Data(0x00);
      TFT_24_7789_Write_Data(0x0A);               // Set Start column at pixel 10
      TFT_24_7789_Write_Data(0x00);
      TFT_24_7789_Write_Data(0x13);               // Set End column at pixel 19

      TFT_24_7789_Write_Command(0x2B);               // Page Address
      TFT_24_7789_Write_Data(0x00);
      TFT_24_7789_Write_Data(0x0A);               // Set Start row at 10
      TFT_24_7789_Write_Data(0x00);
      TFT_24_7789_Write_Data(0x13);               // Set End row at 19

         // Turn the area defined from white to green
      TFT_24_7789_Write_Command(0x2C);

         for (i=0; i<100; i++)   // write out 100 values
         {
            TFT_24_7789_Write_Data(0x07);   // Set color to green
            TFT_24_7789_Write_Data(0xE0);

         }
   }
}

Saurabh_B

  • Administrator
  • Hero Member
  • *****
  • Posts: 355
  • Karma: 10
    • View Profile
Re: [TFT][NHD-2.4-240320CF-CTXI-F][MSP] Interface
« Reply #1 on: October 05, 2015, 11:20:27 AM »
This is what you will see when the display is initialized.

Have you tried writing to it?

« Last Edit: October 06, 2015, 11:14:57 AM by Saurabh_B »

 

NHD‐0420CW‐AB3 I2C Interface

Started by andersonpdBoard OLEDs

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

Started by vinaykBoard OLEDs

Replies: 0
Views: 2044
Last post October 26, 2015, 05:13:10 AM
by vinayk
NHD‐3.12‐25664UMB3 3 or 4 wire interface

Started by cliffgBoard OLEDs

Replies: 1
Views: 2480
Last post February 13, 2015, 04:43:21 PM
by Michael_L
7.0" TFTs with capacitive Touch and 8080 interface availability?

Started by gdoraisaBoard TFTs

Replies: 1
Views: 1213
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: 3221
Last post April 01, 2015, 01:28:00 PM
by Bridgette_E