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

stevestrong Thu Sep 01, 2016 11:53 am

I don’t think that setTextSize() can cause problems.
It is just setting an internal variable:
https://github.com/adafruit/Adafruit-GF … X.cpp#L627
You should check the following tft commands to identify the root cause.
Note:
I have identified a bug (x coordinate underflow) in case of ILI9325, in function setRotation(). When you set rotation to odd number (1 or 3) the printing of text with size = 1 does not work. This is due to a negative value as x coordinate passed to the drawPixel() function, which is generated in the setRotation() function when the maximum y coordinate will be assigned to x.
https://github.com/adafruit/TFTLCD-Libr … D.cpp#L396
Funny, that other text sizes are displayed though.
Maybe this is also related somehow to your problem.

konczakp Thu Sep 01, 2016 7:08 pm

Ok but in my case when I delete setTextSize() it works fine so how is that possible ?

TomaTLAB Fri Sep 02, 2016 6:16 am

stevestrong wrote:…
The other thing is that the LCD works with faster toggling if the LCD is disassembled so that the flexible cable is straight (not bent).
Anyone an idea why?

stevestrong Fri Sep 02, 2016 6:30 am

konczakp wrote:Ok but in my case when I delete setTextSize() it works fine so how is that possible ?

stevestrong Fri Sep 02, 2016 7:41 am

TomaTLAB wrote:
Maybe the flex cable has a several damage, therefore some lines has a high resistance when cable is bent and with the pin capacity forms some kind of LPF.

stevestrong Sat Sep 03, 2016 10:31 am

stevestrong wrote:
yes, I’m afraid that I have to buy another module…

stevestrong Sat Sep 03, 2016 10:32 am

@konczakp
I have tried your code, and it works on my board, with small changes, changed text color to white, removed “#include <gfxfont.h>”.
I had to add in my sketch tft.reset(), tft.readID() and tft.begin(identifier), as the Adafruit lib requires this way (I have ILI9328 controller).
And I got displayed two text lines on the screen with “test” as expected with different sizes.
USB still connected, working with periodic output.
The adapted sketch is the tftpaint.ino included to exmaples (the original tftpaint.ino renamed to tftpain.in).
Attached the original Adafruit lib adapted to STM32.
The used lib is available here.

VadimEL Sat Sep 03, 2016 8:41 pm

konczakp
Yes, I check it, it’s tft.setTextSize(1); problem

then using tft.setTextSize(2); , serial mapple com port did not disconnect.
then tft.setTextSize(1); using one time com port disconnect, then use again -> it’s connect.

konczakp Mon Sep 05, 2016 4:31 pm

@stevestrong
You have a different TFT controller. I have Spfd5408. While trying to use Your library it showed me unknown tft screen but It was also connecting and disconnecting from serial port while checking identifier so there is something wrong with Spfd5408 implementation.

I have tried to remove something else as You said from the code and when I remove tft.println it is working. So the problem is not coming from size but with sending a command to change something on a screen with the given size 1.

the worst thing is that when I open the serial port and send the command to change something on the screen it is disconnecting me and I’m unable to connect again. I have to restart maple mini.

I’m using iwalpola library because this was the only one working perfectly. Any new thoughts what to check else?

stevestrong Mon Sep 05, 2016 6:54 pm

@konczakp
I see two possibilities:
1. try the lib from Joao.
or
2. try my lib and force the identifier to 0x9341 when you call tft.begin.

konczakp Thu Sep 08, 2016 2:39 pm

@stevestrong
I have forced Your lib to run my screen. Unfortunately the problem persists. It is even worse because if I run the testscreen code and I open the serial then the screen and the serial is getting freezed. Sometimes it goes white but every time it stops responding. The other lib is written for Arduino and probably need some tweaking to get it working on stm32. I would rather not to try to do that and end up with the same problem.

If anyone got any idea what to check or change to get this working properly please let me know.

stevestrong Thu Sep 08, 2016 4:34 pm

my last shot:
if using other text sizes than “1” is working, then you could track down the software what happens with “1” by debugging the functions “Adafruit_GFX::write” which is calling “Adafruit_GFX::drawChar”, ultimately these are the lowest level GFX functions. More deeper are the register access functions of the iwalpola lib.
If other sizes also don’t work, then I suspect a power supply problem, you should measure if the 5V and 3.3V of the blue pill if it is OK.
Alternatively try another external 5V supply, although my boards (blue pill + LCD) run perfectly powered from PC USB. I only use the 5V from blue pill to LCD board. On the other hand, the power regulator of the LCD board can also be the problem.

Oh yes, one more thing: if the “graphictest.ino” (together with SPI.begin()) runs without problem, then the iwalpola lib should be ok, which makes the thing even more complicated… :?

konczakp Thu Sep 08, 2016 5:48 pm

Other sizes of the font works perfectly. Only the size 1 is making problem. I have also noticed that when setting size 1 screen is showing slightly different font. Different then with size 2. This problem also persist when I set a custom font. While using custom font serial port is disconnecting every time – this is not related to the size this time. So the problem is for sure with adafruit gfx lib. I was trying to investigate what can cause this problem but I couldn’t find it yet. But I’m still trying. If You have any suggestions how to do it right and fast please tell me. graphictest.ino is also causing the same problem. I’m not suspecting any voltage problem because I would noticed that while doing also other stuff not only tex size change.

stevestrong Thu Sep 08, 2016 5:57 pm

If you think the GFX lib is the problem, I attach my good working local copy, maybe it helps.
Otherwise, to debug, you should add some serial printouts to previously mentioned relevant function. Or use a debugger….

Oh, just came into my mind: are you using the latest stm32duino version from github? Serial has been reworked lately…

konczakp Thu Sep 08, 2016 8:13 pm

Here is what I did:
1. I have downgraded gcc from 4.9 to 4.8
2. I have tried your adafruit library
3. I have tried to modify gfx library to pass double instead int to try to set for example textsize to 1.5 but between 1.1-1.9 nothing changed to the text size – maybe I’ve made something wrong
4. I have updated stm32 under Arduino IDE to the newest version

None of the above have helped :(

stevestrong Thu Sep 08, 2016 8:59 pm

konczakp wrote:
4. I have updated stm32 under Arduino IDE to the newest version

konczakp Thu Sep 08, 2016 9:15 pm

I have downloaded newest version from github as a zip and I have replaced whole old version with a new one. I did as I would install everything from the beginning.

stevestrong Fri Sep 09, 2016 7:22 am

OK, now I think that Joao has had not developed its own version without any reason, so there may be a critical difference between ILI9341 and SPFD5408…
So I would just take my lib (as it is derived from Adafruit lib) as basis and add the special routines from Joao lib specific for SPFD5408. It is very easy to add another type of controller to the lib.
Or: take the Joao lib and adapt it to 8 bit parallel accesses, but I’m afraid this would take you more time than the first suggestion.

As a last suggestion, draw a simple sketch which just writes one character on the LCD with setTextSize(1) and track down which function causes the problem (if there will be any).

EDIT
I just realized that the Joao lib uses the ILI9341 setup, the changes compared to original Adafruit lib are only relevant how to access the registers (for Arduino Uno and Mega), but no difference at all in register values.
So I would stick to my last suggestion to find the root cause, using iwalpola’s lib.
Double check wiring and pin definitions.

konczakp Mon Oct 03, 2016 6:16 pm

Now about the backlight. I know that there is no easy way like changing register to dim the backlight or even get it off (If I’m wrong show me how). But there is a way to do it! :) Screen can work without +5 VCC. It can be attached and detached to power on/off or You can put a resistor to make it dimmed. In my situation I don’t have any free pwm pin which would be most suitable to get it dimmed so I need to use digital one with a resistor on it. And now the hard part which I don’t know how to do. I was trying some NPN and PNP transistors, MOSFET and optocouplers. None of it worked for me because they need to be connected with + and gnd but I need to switch on/off only the hot wire (+). To be more clear I need to apply high on pin for ex PB2 to connect +5 from usb to +5 on tft screen. Any idea how to do it? I didn’t try to use ssr but I don’t want to use mechanical relay.

___________+5V USB
|
pin PB2 ----------------| on / off
|__________ +5V TFT

stevestrong Mon Oct 03, 2016 7:48 pm

The transistor is type PNP.
The upper resistor can be 4k7 as well.
The TFT background is powered when the output-drain GPIO is tied low to “0”.

Sign in to reply