Bodmer / TFT_ILI9341

A fast Arduino IDE compatible graphics and fonts library including a driver for the ILI9341 based TFT displays.
109 stars 32 forks source link

SD library issues #3

Closed oldmanegan closed 7 years ago

oldmanegan commented 7 years ago

Hi, After many, many hours of troubleshooting and testing here is what I came up with as a corner case and resolution: Using an Atmel 1284P chip as MCU and Seeed 2.8 TFT screen. Loading an SPI and SD library modified for the 1284P (ones on Github) as well as your library... I modified the User_Setup.h file to be set for the Maniac layout (yet still using factory SPI pins while ignoring the Seeed guidance to not use the CS pin for the screen (since they expect the screen attached to a standard Arduino board where they used a different digital pin for CS, and I am connecting differently). I had to load the SD library before yours. I created the File for SD card before setting the tft object. I had the line of code SD.begin() before any TFT related code in Setup.

Only then did it work and not freeze when attempting to write to screen after a touch event. I tried activating the transaction statement in User_Setup, I tried different SPI speeds and even SPI settings per SD card I/O and TFT screen, and even in the TFT_FastPin.h file for the 1284 entry the need to change the pin assignments to make them accurate for HW SPI did not help:

define SPI_DATA 5

define SPI_CLOCK 7

define SPI_SELECT 4

define AVR_HARDWARE_SPI

Any thoughts?

Bodmer commented 7 years ago

I do not have a 1284P based board to try the library on and I do not know what a "Maniac layout" is so I am not sure what you are asking, or what problem you are trying to solve.

So this is a guess at your problem.

If you have two SPI peripherals on the same bus the chip select lines need a pullup on the chip select lines need to be set high in the sketch before either library is called otherwise a chip select line will be "floating" and hence access conflicts on the SPI bus can occur. Many libraries do not take this into account. The TFT_ILI9341 library sets the chip select line high in the constructor in an attempt to get things into a good state before other SPI initialisation code is called.