I've been working on adding ili9341 support for my (non-arduino Teensy++ 2.0) project, using PJRC's most excellent Arduino library as an example. I've been banging my head for a couple of evenings trying to get either of the ili9341 LCDs (2.2" and 2.8") to display anything. I think I have it coming out of reset, but looking at the SPI bus while doing a "Read Display Status" command looks like the LCD is trying to send data back while ignoring the SPI clock and with a bit-width that makes me think I've got it into a weird mode without realizing it.
Here is an example of a read display status. Note the short pulses on MISO right after the command completes.
View attachment 6241
Zoomed in.
View attachment 6242
I'm using the initialization sequence out of the PJRC optimized driver for now (also tried the one in the original Adafruit library). The relevant and not terribly fancy code is below. The SPI_WRITE / SPI_READ macros simply copy the data to/from the SPDR register after checking SPSR (verbatim from the datasheet and every example online).
I've ruled out power (5V to VCC of the board, 3.3V for the logic) and nothing is obviously incorrectly hooked up. I'm pretty sure I'm doing reset correctly, at least compared to the datasheet and examples online. The code's pretty simple at this point because I'm not going further until I can at least get *some* data or draw a pixel to the screen. Does anyone have a capture of the SPI bus of a working LCD I could use to figure out what I'm doing wrong? (Or other suggestions on places to check.)
Thanks!
- Jack
-- Code snippet begin ---
void ili9341_write_cmd(uint8_t cmd)
{
LCD_PORT &= ~_BV(LCD_DCX);
LCD_SS_ASSERT();
SPI_WRITE(cmd);
LCD_PORT |= _BV(LCD_DCX);
}
void ili9341_read_display_status(void)
{
uint32_t data;
ili9341_write_cmd(ILI9341_CMDL1_RDDST);
ili9341_read_data(); // dummy
ili9341_read_data();
ili9341_read_data();
ili9341_read_data();
LCD_SS_DEASSERT();
}
inline uint8_t ili9341_read_data(void)
{
uint8_t data;
LCD_PORT |= _BV(LCD_DCX);
LCD_SS_ASSERT();
SPI_READ(data);
return data;
}
Here is an example of a read display status. Note the short pulses on MISO right after the command completes.
View attachment 6241
Zoomed in.
View attachment 6242
I'm using the initialization sequence out of the PJRC optimized driver for now (also tried the one in the original Adafruit library). The relevant and not terribly fancy code is below. The SPI_WRITE / SPI_READ macros simply copy the data to/from the SPDR register after checking SPSR (verbatim from the datasheet and every example online).
I've ruled out power (5V to VCC of the board, 3.3V for the logic) and nothing is obviously incorrectly hooked up. I'm pretty sure I'm doing reset correctly, at least compared to the datasheet and examples online. The code's pretty simple at this point because I'm not going further until I can at least get *some* data or draw a pixel to the screen. Does anyone have a capture of the SPI bus of a working LCD I could use to figure out what I'm doing wrong? (Or other suggestions on places to check.)
Thanks!
- Jack
-- Code snippet begin ---
void ili9341_write_cmd(uint8_t cmd)
{
LCD_PORT &= ~_BV(LCD_DCX);
LCD_SS_ASSERT();
SPI_WRITE(cmd);
LCD_PORT |= _BV(LCD_DCX);
}
void ili9341_read_display_status(void)
{
uint32_t data;
ili9341_write_cmd(ILI9341_CMDL1_RDDST);
ili9341_read_data(); // dummy
ili9341_read_data();
ili9341_read_data();
ili9341_read_data();
LCD_SS_DEASSERT();
}
inline uint8_t ili9341_read_data(void)
{
uint8_t data;
LCD_PORT |= _BV(LCD_DCX);
LCD_SS_ASSERT();
SPI_READ(data);
return data;
}