0

TFT - D/C
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

TFT - D/C

by mike808 on Sun Nov 03, 2013 4:26 pm

Hi, I puchased a TFT display (http://www.adafruit.com/products/1480) and it works well with my Arduino. I am currently writing some code on my Raspberry Pi to drive this display and to learn more about SPI. When using with the arduino, I had pin 8 connected to D/C pin on the display. What is D/C and what would that map to on the Raspberry Pi? From looking at the code, i'm guessing it has something to do with the hardware SPI which I would want to take advantage of for performance. thank you!

mike808
 
Posts: 71
Joined: Sat May 25, 2013 10:22 pm

Re: TFT - D/C

by adafruit_support_rick on Mon Nov 04, 2013 11:20 am

D/C selects data or command mode when writing to the display. Set D/C low before writing a command, set D/C high before writing data.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: TFT - D/C

by mike808 on Wed Nov 06, 2013 7:58 pm

What speed and bits_per_word should i be using when communicating with SPI and this display?

Code: Select all | TOGGLE FULL SIZE
   struct spi_ioc_transfer spi[length];
   int i = 0;
   int retVal = -1;

   // one spi transfer for each byte

   for (i = 0 ; i < length ; i++)
   {
      spi[i].tx_buf        = (unsigned long)(data + i);
      spi[i].rx_buf        = (unsigned long)(data + i) ;
      spi[i].len           = sizeof(*(data + i)) ;
      spi[i].delay_usecs   = 0 ;
      spi[i].speed_hz      = ???;  // <-- what to put here?
      spi[i].bits_per_word = ???;  // <-- what to put here?
      spi[i].cs_change = 0;
   }

mike808
 
Posts: 71
Joined: Sat May 25, 2013 10:22 pm

Re: TFT - D/C

by adafruit_support_rick on Thu Nov 07, 2013 8:10 am

The value for bits should be 8. You want to format your data as shown in 4-line 18-bit mode on page 63 of the datasheet
http://www.adafruit.com/datasheets/ILI9340.pdf

I didn't spot any specific instructions on the data clock rate in the datasheet, but you should be OK at 400kHz. Once you get that working, try 800kHz, and then keep bumping it up from there.

adafruit_support_rick
 
Posts: 35095
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: TFT - D/C

by mike808 on Mon Nov 18, 2013 11:32 pm

I've been banging my head on this and can't get it to work. Are there any userspace example programs that demonstrates this? I've tried frequencies from 400kHz 1000kHz with no success. I'm not sure what I'm doing wrong and would very much appreciate some help please.

mike808
 
Posts: 71
Joined: Sat May 25, 2013 10:22 pm

Please be positive and constructive with your questions and comments.