Spark Logic

8-bit|16-bit parallell ILI9341

andreas_ferm

Good day everyone, I’m all new to stm32 and have previously only done smaller projects on arduiono boards, mostly using already-finished libraries.

Now I reached a point where my programmings skills lack, so instead of optimizing my code i started to look at maple mini and thought it would be excellent to also add a “nice” GUI to my project.

I ended up ordering a chinese 3.2″ tft+touch+sd card combo, but what i didn’t know or think of beforehand was to check the connectivity needed (i just read here and saw all the included libraries for the aforementioned display controller), but all of them are using SPI. So the display came in the mail and i became aware that it didn’t have any SPI interface, (at least not for the display, only for the touch and sd card)

Are there any working options that is available to use with stm32duino? What would be my best chance of getting this to work? (i was initially thinking about going for a MEGA, but choose the maple mini clone as i was impressed with the various tft demos i’ve seen )

I’ve tried looking through “all” of the internet, but have only found small pointers, and none of the really targeted for stm32duino. (i found one post where someone had posted an utft version with support for stm32, which was based on some teensy port, but it was also done for SPI only, and i couldn’t find any ILI9341 tft ‘drivers’ for parallel communication… well there was one for an ILI9481 but i’m not sure if that can be used in direct replacement.

Anyone has a similar display and has it working with a maple mini?

Thanks!
Andreas

Replies20

konczakp Wed Jul 27, 2016 7:24 pm

Can you specify the connection between tft and stm32?

stevestrong Wed Jul 27, 2016 7:37 pm

for the touch pins, see defines from the INO sketch.
The SD card connection, additionally to 5V extern and GND from pill, is straightforward.

Be careful: don’t mix port names PAx with Ax !
STM32 TFT
PA4 SD_SS
PA5 SD_SCK
PA6 SD_DO (=MISO)
PA7 SD_DI (=MOSI)

cologne86 Wed Jul 27, 2016 8:17 pm

stevestrong wrote:Regarding how to identify the touch pins, it is suggested that the resistance between XM-XP and YM-YP should be measured.
One pair has a bit larger resistance than the other pair because of the display geometry (4:3), I suppose.
In this way I figured out that on my display the touch pins are mapped as follows:
(XP-XM): LCD_WR – D0 = ~330 ohm
(YP-YM): LCD_CD(or _RS) – D1 = ~500 ohm
So, in my case, it is not D6 and D7 which are used, as posted earlier.
But I think it is different from display to display.

stevestrong Wed Jul 27, 2016 8:39 pm

Well, if you do not connect any other pin, and you do not touch the display during measuring, and the plate resistance is changing, it only can hint to a hardware malfunction, i assume.

cologne86 Thu Jul 28, 2016 9:38 am

stevestrong wrote:Well, if you do not connect any other pin, and you do not touch the display during measuring, and the plate resistance is changing, it only can hint to a hardware malfunction, i assume.

stevestrong Thu Jul 28, 2016 11:31 am

Data lines D0…D7 are switched through U3, which is controlled by the LCD_RD signal.
Be sure that this pin is set to “high” (“1”) to use the touch pins.

cologne86 Thu Jul 28, 2016 11:45 am

stevestrong wrote:Data lines D0…D7 are switched through U3, which is controlled by the LCD_RD signal.
Be sure that this pin is set to “high” (“1”) to use the touch pins.

stevestrong Thu Jul 28, 2016 12:03 pm

Do you supply the board with 3.3V or 5V?
If you use the 3.3V from the blue pill (STM32), it may not be enough to drive the backlight, SD card and the LCD all together.
I would suggest you to use 5V.

cologne86 Thu Jul 28, 2016 1:02 pm

I connected both.

stevestrong Thu Jul 28, 2016 8:18 pm

cologne86 wrote:I connected both.

stmNoob0xFF Tue Aug 02, 2016 2:07 am

Hi!

I’ve been reading through this thread, and am getting a little lost..

I have a TFT (as mentioned earlier) labelled “TFT_320QVT_9341”.

It has DB0 – DB-15.

Which lib should I be using, and is it still possible to change the pin config on the STM32F4(Discovery)?

Is there any reference as to how other people have routed in and configured?

(There seem to be a lot of sketches, but I am unsure which one I should be following).

konczakp Sat Aug 06, 2016 12:29 pm

hello everyone … I have just came back from my holidays :) and I’m back to my project with the tft and sd card.

@stevestrong I have tried Your sd card code and unfortunately it is not working :( I have connected as You mentioned but still nothing. I have bought even another board to do tests (maple mini) but nothing changed :x I was trying via 5v and after that with 3.3v and at last both. I have connected only pins for the sd card, everything else is not connected. I don’t really know what I’m doing wrong, I think I’m missing some small part which I don’t see or I don’t know where is the problem. I know that the card is working because I did a test with arduino and a simple code cardinfo from adruino IDE. On ardiono everything works fine but not on the maple mini / blue pill.

Because I don’t know how to find a problem below is my code and connection schematics :

connection


FTDI maple mini TFT_SD
(USB-to-RS)
| -----Rx------|------Tx-------|
| -----Tx------|------Rx-------|
| ----GND------|------GND------|-----GND------|
| ----+3v------|------VCC------|
|------PA4------|----SD_SS-----|
|------PA5------|----SD_SCK----|
|------PA6------|----SD_MISO---|
|------PA7------|----SD_MOSI---|
|------+5v-----|---------------> +5v from USB (GND already connected via PC and FTDI)

konczakp Sat Aug 06, 2016 2:15 pm

OK I have solved it out! :) :)

For me this code is working :


/*
SD card read/write

created Nov 2010
by David A. Mellis
modified 9 Apr 2012
by Tom Igoe

This example code is in the public domain.

*/

#include <SPI.h>
#include <SD.h>

File myFile;

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
delay(4000);

Serial.print("Initializing SD card...");

if (!SD.begin(PA4)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");

// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);

// if the file opened okay, write to it:
if (myFile) {
Serial.print("Writing to test.txt...");
myFile.println("testing 1, 2, 3.");
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}

// re-open the file for reading:
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("test.txt:");

// read from the file until there's nothing else in it:
while (myFile.available()) {
Serial.write(myFile.read());
}
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
}

void loop() {
// nothing happens after setup
}

Pito Sat Aug 06, 2016 2:16 pm

Try to use SdFat from here (the SdFat’s author github):
https://github.com/greiman/SdFat
Try the examples, it should work.
PS: the above code is old.

konczakp Sat Aug 06, 2016 2:22 pm

Thanks Pito! I will try that out later because it started to worki with sd library I think I will stick to this one. Until it will stop working because I want to move sd card to SPI2 :)

stevestrong Sat Aug 06, 2016 10:08 pm

I sent a PR to victor, it contains important changes, he did not update his repo.
So try the version from my repo.

RogerClark Sat Aug 06, 2016 10:15 pm

Steve

Victor has not been on the forum for ages, I think we have to assume he is no longer actively maintaining any of his repo’s etc

stevestrong Sat Aug 06, 2016 10:20 pm

Roger, in this case i would suggest to include the sd fat lib to stm32duino official libs, what do you think?

RogerClark Sun Aug 07, 2016 12:36 pm

I thought the official lib from the original author was supposed to work OK.
Or did Victors changes not get implemented by the original author of the lib ?

Sign in to reply