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 - MidknighTrain

Pages: [1]
1
TFTs / Unable to get LCD to display color
« on: September 16, 2016, 08:50:42 PM »
Hi all,

I'm having some trouble interfacing with this LCD that I'm working with. The model for the LCD is NHD-5.0-800480TF-ATXL#-CTP, and it uses the controller board NHD‐5.0‐800480TF‐34 with built-in SSD1963 controller chip. The LCD has a total of 40 pins that connects to the controller board through a ribbon cable, and the controller board give users access to 34 pins to connect to the MCU, also using a ribbon cable (plus some adapters to connect to the breadboard that I have the launchpad plugged into). Here are some extra datasheets for reference. They are in the order of LCD, controller board, and then controller chip SSD1963.

http://www.newhavendisplay.com/specs/NHD-5.0-800480TF-ATXL-CTP.pdf
http://www.newhavendisplay.com/specs/NHD-5.0-800480TF-34%20Controller%20Board.pdf
http://www.newhavendisplay.com/appnotes/datasheets/LCDs/SSD1963.pdf


I found the code for the Arduino Mega on the company's website, and thus I transfer that over into C for the Tiva C laucnhpad. Here is the link to the Arduino code, followed by the app notes for the SSD1963, with the difference that this one came from the actual company that made the chip itself (the code examples from the app notes seems to match the ones on the display company's website):

http://www.newhavendisplay.com/app_notes/Arduino_nhd-5_0-800480TF.txt
http://www.solomon-systech.com/files/ck/files/SSD1961_2_3_Application_note_v1.7.pdf


And now here is my code:

//*****************************************************************************
//
// Main routine.
//
//*****************************************************************************
int main(void)
{
   //
    // Run from the PLL at 120 MHz.
    //
   uint32_t g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
         SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);

    //
    // Initialize peripherals.
    //
   initLCD(g_ui32SysClock);

   //
   // Setup LCD for display.
   //
   lcdSetup(g_ui32SysClock);

    //
    // Main loop.
    //
    while (1)
    {
       lcdDemo(g_ui32SysClock);

       MAP_SysCtlDelay(g_ui32SysClock / 3); // 1 s delay
    }
}

//*****************************************************************************
//
// Initialize LCD.
//
//*****************************************************************************
void initLCD(uint32_t g_ui32SysClock)
{
   //
   // Enable the peripherals to be used.
   //
   MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOH);
   MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOM);
   MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOQ);
   MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);

   //
   // Waits for peripherals to be ready.
   //
   while (!MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOH) &&
         !MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOM) &&
         !MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOQ) &&
         !MAP_SysCtlPeripheralReady(SYSCTL_PERIPH_GPIOL));

   //
   // Configure pin PQ3 as output.
   //
   MAP_GPIOPinTypeGPIOOutput(GPIO_PORTQ_BASE, GPIO_PIN_3);

   //
   // Configure pin PH0-PH3 as output.
   //
   MAP_GPIOPinTypeGPIOOutput(GPIO_PORTH_BASE, GPIO_PIN_0 | GPIO_PIN_1 |
         GPIO_PIN_2 | GPIO_PIN_3);

   //
   // Configure pin PM0-PM7 as output.
   //
   MAP_GPIOPinTypeGPIOOutput(GPIO_PORTM_BASE, GPIO_PIN_0 | GPIO_PIN_1 |
         GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 |
         GPIO_PIN_7);

   //
   // Configure pin PL0 as output.
   //
   MAP_GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE, GPIO_PIN_0);
}

//*****************************************************************************
//
// Setup/initialize LCD.
//
//*****************************************************************************
void lcdSetup(uint32_t g_ui32SysClock)
{
   //
   // Drive DISP & RD HIGH.
   // Drive WR & REST LOW.
   //
   MAP_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 |
         GPIO_PIN_3, 0x0A);
   MAP_SysCtlDelay(g_ui32SysClock / 3 / (25/3)); // 120 ms delay

   //
   // Drive REST HIGH.
   //
   MAP_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_2, 0x04);
   MAP_SysCtlDelay(g_ui32SysClock / 3 / (25/3)); // 120 ms delay

   //
   // Perform software reset.
   //
   lcdWriteCommand(0x01);
   MAP_SysCtlDelay(g_ui32SysClock / 3 / (25/3)); // 120 ms delay

   //
   // Set multiplier and divider for PLL.
   //
   lcdWriteCommand(0xE2);
   lcdWriteData(0x1D);
   lcdWriteData(0x02);
   lcdWriteData(0x04);

   //
   // Enable and lock PLL.
   //
   lcdWriteDataToReg(0xE0, 0x01);
   MAP_SysCtlDelay(g_ui32SysClock / 3 / 1000); // 1 ms delay
   lcdWriteDataToReg(0xE0, 0x03);

   //
   // Perform software reset.
   //
   lcdWriteCommand(0x01);
   MAP_SysCtlDelay(g_ui32SysClock / 3 / (25/3)); // 120 ms delay

   //
   // Set LCD mode.
   //
   lcdWriteCommand(0xB0);
   lcdWriteData(0x08);      // 18-bit, FRC enable, dithering disable
   lcdWriteData(0x80);      // TFT mode
   lcdWriteData(0x03);      // Horizontal size = 800 - 1; high byte
   lcdWriteData(0x1F);      // Horizontal size = 800 - 1; low byte
   lcdWriteData(0x01);      // Horizontal size = 480 - 1; high byte
   lcdWriteData(0xDF);      // Horizontal size = 480 - 1; low byte
   lcdWriteData(0x00);      // Even/odd line RGB sequence = RGB

   //
   // Set pixel data format to 8-bit.
   //
   lcdWriteDataToReg(0xF0, 0x00);

   //
   // Set address mode. Image is flipped vertically on display. RGB order from
   // is buffer to display is flipped to BGR.
   //
   lcdWriteDataToReg(0x36, 0x09);

   //
   // Set pixel clock frequency.
   //
   lcdWriteCommand(0xE6);
   lcdWriteData(0x0F);
   lcdWriteData(0xFF);
   lcdWriteData(0xFF);

   //
   // Set horizontal period.
   //
   lcdWriteCommand(0xB4);
   lcdWriteData(0x04);      // HSYCN total = 1056; high byte
   lcdWriteData(0x20);      // HSYCN total = 1056; low byte
   lcdWriteData(0x00);      // HSYNC start position = 88; high byte
   lcdWriteData(0x58);      // HSYNC start position = 88; low byte
   lcdWriteData(0x80);      // HSYNC pulse width = 128 = 127pixels + 1
   lcdWriteData(0x00);      // HSYNC pulse start position; high byte
   lcdWriteData(0x00);      // HSYNC pulse start position; low byte
   lcdWriteData(0x00);      // HSYNC pulse subpixel start position

   //
   // Set vertical period.
   //
   lcdWriteCommand(0xB6);
   lcdWriteData(0x02);      // VSYCN total = 525; high byte
   lcdWriteData(0x0D);      // VSYCN total = 525; low byte
   lcdWriteData(0x00);      // VSYNC start position = 32; high byte
   lcdWriteData(0x20);      // VSYNC start position = 32; low byte
   lcdWriteData(0x01);      // VSYNC pulse width = 1 = 0lines + 1
   lcdWriteData(0x00);      // VSYNC pulse start position; high byte
   lcdWriteData(0x00);      // VSYNC pulse start position; low byte

   //
   // Go into normal mode. Whole display area is used.
   //
   lcdWriteCommand(0x13);

   //
   // Exit idle mode. Full color depth is used for display.
   //
   lcdWriteCommand(0x38);

   //
   // Show image.
   //
   lcdWriteCommand(0x29);
   MAP_SysCtlDelay(g_ui32SysClock / 3 / 100); // 10 ms delay
}

//*****************************************************************************
//
// Test function.
//
//*****************************************************************************
void lcdDemo(uint32_t g_ui32SysClock)
{
   uint16_t i = 0;
   uint16_t j = 0;

   //
   // Set start and end position for column/page address. (full screen)
   //
   lcdWindowSet(0, 799, 0, 479);

   //
   // Start transaction from MCU to display.
   //
   lcdWriteCommand(0x2C);

   //
   // Fill screen with blue pixels.
   //
   for (; i < 480; ++i)
   {
      for (; j < 800; ++j)
      {
         lcdWriteData(0xFF);
         lcdWriteData(0x00);
         lcdWriteData(0x00);
      }
   }
   //
   // Set start and end position for column/page address. (full screen)
   //
   lcdWindowSet(0, 799, 0, 479);

   //
   // Start transaction from MCU to display.
   //
   lcdWriteCommand(0x2C);

   //
   // Fill screen with green pixels.
   //
   for (; i < 480; ++i)
   {
      for (; j < 800; ++j)
      {
         lcdWriteData(0x00);
         lcdWriteData(0xFF);
         lcdWriteData(0x00);
      }
   }

   //
   // Set start and end position for column/page address. (full screen)
   //
   lcdWindowSet(0, 799, 0, 479);

   //
   // Start transaction from MCU to display.
   //
   lcdWriteCommand(0x2C);

   //
   // Fill screen with red pixels.
   //
   for (; i < 480; ++i)
   {
      for (; j < 800; ++j)
      {
         lcdWriteData(0x00);
         lcdWriteData(0x00);
         lcdWriteData(0xFF);
      }
   }
}

//*****************************************************************************
//
// Send a command to LCD.
//
//*****************************************************************************
void lcdWriteCommand(unsigned char command)
{
   uint8_t all_pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 |
         GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;

   //
   // Drive RS LOW to send command.
   //
   MAP_GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_3, 0x00);

   //
   // Send 8-bit all together.
   //
   MAP_GPIOPinWrite(GPIO_PORTM_BASE, all_pin, command);

   //
   // Toggle WR. (Active LOW)
   //
   MAP_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_0, 0x00);
   MAP_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_0, 0x01);
}

//*****************************************************************************
//
// Send data to LCD.
//
//*****************************************************************************
void lcdWriteData(unsigned char data)
{
   uint8_t all_pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 |
         GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7;

   //
   // Drive RS HIGH to send data.
   //
   MAP_GPIOPinWrite(GPIO_PORTQ_BASE, GPIO_PIN_3, 0x08);

   //
   // Send 8-bit all together.
   //
   MAP_GPIOPinWrite(GPIO_PORTM_BASE, all_pin, data);

   //
   // Toggle WR. (Active LOW)
   //
   MAP_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_0, 0x00);
   MAP_GPIOPinWrite(GPIO_PORTH_BASE, GPIO_PIN_0, 0x01);
}

//*****************************************************************************
//
// Write/overwrite value in specified register.
//
//*****************************************************************************
void lcdWriteDataToReg(unsigned char reg, unsigned char val)
{
   lcdWriteCommand(reg);
   lcdWriteData(val);
}


Here are some tests that I've did so far:

- Connected a logic analyzer to an oscilloscope, hooked the probes to the data pins PM0-PM7, hooked the channel 1 probe to the WR signal, and stepped through each line in the code to make sure that all values that are sent are being sent as specified.

- Wrote color data to frame buffer, then reading it back out. All data are the same coming out as how they came in, proving that the MCU is communicating correctly with the SSD1963.


Possible causes:

- The LCD or the circuitry on ribbon cable flap connecting to the controller board is faulty/short-circuited.

- I missed something when I transferred the code from Arduino to C.

- I'm not setting the Horizontal Period, Vertical Period, and/or the PLL multiplier and divider correctly (though I've looked through the datasheet for the values on this and I'm quite certain that they are set to the correct values, though I could be wrong, as I'm not 100% sure).


I've been stuck on this for the past couple of weeks, and I'm in desperate needs to get this done in time for my school project. Does anyone have any sort of idea (or have even worked with a NewHaven Display before) on what I might have done wrong, or what other tests I could do?

Thanks a bunch.

2
TFTs / FT5306 Registers 0x80-0x89
« on: September 02, 2016, 09:25:58 PM »
Hi,

Could someone explain to me what each of the register from 0x80 to 0x89 does? I'm trying to understand them by playing with each one to see how it changes the panel's sensitivity, but I can't tell what each does exactly. I tried setting them to the recommended values, but for some reason the touch panel sometimes randomly reads in values that aren't supposed to be there (reading in 5 touches when I'm only using one finger, etc.). Also, it reads in multiple sets of values for one single touch (which I'm guessing should be 3 in total for Put Down, Contact, then Put Up? Which one should I be using? Either one of the three?). Lastly, I tried writing into register 0x83 and 0x84, but for some reason I'm getting back the value 0x00 for both of those, while the rest of the other registers were able to write in the new values I specified. Sorry for having so many questions on one post.

Thanks

3
The datasheet for this controller board can be found here:
http://www.newhavendisplay.com/specs/NHD-5.0-800480TF-34%20Controller%20Board.pdf

I'm having trouble getting the back light to turn on. After looking more carefully at the board, pin 3 (B/L Enable) on the 34-pin MPU side isn't connected to pin 2 on the 40-pin LCD side (there isn't any pathway leading out from pin 3). I'm pretty new to doing embedded programming and stuff, and I was wondering how I can turn on the back light for the display? Is it possible using this controller board? The display I'm using is the NHD-5.0-800480TF-ATXL#-CTP if that info is needed.

Also, according to this datasheet here for the LCD, http://www.newhavendisplay.com/specs/NHD-5.0-800480TF-ATXL-CTP.pdf, it says that the back light requires 60 mA @ 19.2 V, but on the other one for the controller board, it says 20 mA @ 23.1 V instead. Does this means that either or can be used, or....what? Sorry I'm a little confused at this part.

Thanks

Pages: [1]