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 Oct 06, 2016 2:27 pm

I personally find very strange, that the SD-adapter on the LCD board is working without being supplied either from 5V or 3.3V.
The problem is, we don’t know exactly how the schematic of the board looks like.
I would desolder the small 3.3V adapter from the board and supply the 3.3V from STM32 board. Moreover, you need to make a short from the 3.3V pin of the LCD board to the 3.3V line (adapter output) on the board, because, as far as I know, there is no connection per default.
Pin 12 (PC15) is giving High and Low to the base of PNP transistor.
How does the signal look like? Do you set it high and low intermittently in the main loop? Where exactly (relative to other sw functions)? How fast?

Pito Thu Oct 06, 2016 3:20 pm

I’m using this circuit to switch +5V to TFT. Pin 12 (PC15) is giving High and Low to the base of PNP transistor.
Your circuit is ok. You do not need the 4k7 resistor to ground. Let the 120ohm in series with +TFT (before leds). The white screen a little bit dimmed is ok. That means you do not have any graphics displayed.
PC15 has to be configured as an open drain output. With standard push-pull output it may not work properly (see my previous post). Again: Open Drain output PC15 with your above high side PNP switch.
PS: we really need to know at least your board’s link at ebay or better the schematics. It may happen your display has got only +5V VCC, and a 3.3V voltage regulator on it. The LEDs positive anodes could be connected to 5V or 3.3V internally and the LEDs negative cathodes are connected to a LED_GND pin. The second GND pin could be the master GND. Then you have to use low side NPN switch, collector connected to LED_GND via 120ohm resistor.
With single +5V on the board you will switch entire board off/on with the high side PNP switch.
Weird, isn’t it? :)
With the NPN low side switch the PC15 must stay standard output (not open drain).
low side led switch.JPG
low side led switch.JPG (14.95 KiB) Viewed 747 times

konczakp Thu Oct 06, 2016 7:08 pm

This is my tft board. Unfortunately I don’t have any schematics.
I personally find very strange, that the SD-adapter on the LCD board is working without being supplied either from 5V or 3.3V.
I could be wrong but I think it is powered from other pins

I’ve tried to power screen via 3.3V (not by the pin but directly to the voltage regulator 3.3v output) but it is still blinking

How does the signal look like?
I’ve made a timer with millis() which is counting down 6 sec and after that it is switching off the screen then if I touch the screen it is powering on and starts the countdown for off.

The white screen a little bit dimmed is ok. That means you do not have any graphics displayed
I’m afraid that in my case this is not true because if I’m not putting this resistor graphics is being shown and with this resistor it is not. Of course while using that circuit.

Open Drain output PC15
I have tried that already with pnp transistor but this didn’t change anything

The second GND pin could be the master GND. Then you have to use low side NPN switch, collector connected to LED_GND via 120ohm resistor.
Both GND pins are connected at the same point and it doesn’t matter which I connect. There is no LED_GND there is only one GND.

I have also tried PNP driven by NPN but no change

But there is another thing I have noticed. Then I take out sd card from sd slot it stops blinking :/

ahull Thu Oct 06, 2016 10:57 pm

Interesting…
Display.jpg
Display.jpg (94.63 KiB) Viewed 724 times

ahull Thu Oct 06, 2016 11:31 pm

ahull wrote:Interesting…
Display.jpg

konczakp Fri Oct 07, 2016 7:35 am

I’ve red those posts at the beginning but they don’t discuss anything what could be helpful in my case. :(

It has a couple of 74HC245 tri-state buffers on it, so may multiplex the display signals in some strange way
I know but I have no idea how to track which is the backlight connection. If we will not be able to get this done I think the only way will be to destroy the shield and check all the paths on the board to see which is which :cry:

stevestrong Fri Oct 07, 2016 7:37 am

@konczakp,
it is not OK that you don’t give any dedicated power supply to LCD. It seems that now you are supplying the LCD board over the data/control pins from the STM32.
You should feed the LCD board with the 3.3V from STM32, with additional wire soldered between LCD bord pin 3V3 and the 5V<>3.3V power adaptor output (3.3V) pin. This wouldn’t be normally needed, but if you want to control the 5V, you have no other alternative.
If you don’t do this, it is normal that the power collapses when SD card is accessed, it needs some high current pulses when writing/reading data. If you take the SD card out, it will work.

Pito Fri Oct 07, 2016 10:16 am

I deleted my advice as I have found

https://forum.arduino.cc/index.php?topi … msg2451927
https://forum.arduino.cc/index.php?topi … msg2451875

the guys say the backlight cannot be switched off, you have to hack the board as the backlight is hardwired.
Also there is a warning in the above thread the 5V signals (or 5V Vcc??) may *propagate via 245 buffers onto sdcard’s VCC (somebody measured up to 4.3V on the sdcard’s socket).
https://forum.arduino.cc/index.php?topi … msg1764859

I would therefore not use 5V, but 3.3V Vcc only. And 3.3V signals, of course.

*Pito: It is possible via the clamping protection diodes each cmos device gets on its inputs/outputs.

konczakp Sat Oct 08, 2016 7:03 pm

Because there is not such a thing described over the internet (or I couldn’t find it) I will write what I have accomplished. I have sacrificed 8-) 2 of my screens to check how can I connect the led control. I’ve checked one cheaper and one more expensive. Both were bought on the ebay. First about the cheaper. It was KeDei as I mentioned before. Desoldering the voltage regulator and supplying 3.3v instead didn’t change anything. It was even worse. I think this is because voltage regulator on board can give more current then directly connected 3.3v from the maple mini. This screen in my opinion has inappropriate designed connections and that is why it is blinking. Screen should have three +3.3v wires connected only for powering the screen but in this case it has only two. I’m not counting led power supply. I’m deducting this from the other screen which is not blinking and which is similar to this one and it has 3 power supply. Blinking will be not noticeable if there is no sd card used. There is also something messed up with other connections because without supplying +5v to the screen it should not be working because it lack main power supply and it saturates power from other pins somehow. But it works and this is weird.
Let’s get back to LED on/off. With this screen I would have to cut the bold path (see magnified section) and solder a tiny wire to make a control via PNP transistor. In way that was described before. This will allow me to switch on/off backlight leds but it will still be blinking because of the sd card. Second problem is not to break the screen while disassembly :D They have used a lot of tape to connect the screen with the board. So do it on Your own risk
TFT.jpg
TFT.jpg (134.31 KiB) Viewed 886 times

stevestrong Sat Oct 08, 2016 8:21 pm

I have exactly the same display as your expensive one (second picture). It has ili9328 driver chip.
Thanks for dicovering the backlight control possibilty, i may use it later some time.

Pito Sat Oct 08, 2016 8:59 pm

Can some one provide properly working circuit for the NPN transistor to drive the led on/off? Is it possible to drive the NPN transistor with PWM to change brightness of the led?
..for example the NPN low side switch in the schematics below. There is no other better circuit, afaik..
http://www.stm32duino.com/viewtopic.php … 220#p18680
Low at PC12 switches LEDs off, 3.3V High switches LEDs on. Simply cut off the gnd side trace of the LED’s resistor on the board, and wire the gnd side of the resistor to the collector of the NPN transistor. What value of the resistor they use on the board?
If you want to use fast PWM you may decrease the R1 and R2 to say 3k3.

konczakp Mon Oct 10, 2016 6:52 pm

8-) It’s working!
TFT screen had 2.2 Ω but I’ve changed it to 5 Ω so in this circuit instead 100 Ω I gave 5 Ω and it’s working perfectly!

ahull Mon Oct 10, 2016 7:24 pm

I suspect that 2.2 Ω is far too high for your voltage regulator to cope with, it would allow a maximum current of around 1.5A to flow through the LEDs, assuming white LEDs that drop nearly the full 3.3V which (assuming there are 4 LEDs) may allow 375mA per LED (or even more through an individual LED if they are not well matched).

Even 5 Ω sounds a little excessive, have you tried measuring the current through your 5 Ω resistor, I suspect it will be of the order of 660 mA. All of this assumes there is no other current limiting resistor of course, which seems likely given the boards tendency to brown out the PSU. I would think that 22 Ω might be a more sane value as this would limit the per LED current to around 40mA and a potential maximum of around 165mA if things go a little pear shaped and one LED fails short circuit.

If you cannot measure the current through the resistor directly, measure the voltage drop across it, and fire it through Ohms law (I=V/R)

EDIT: In all of the above, I am assuming a perfect transistor, and the driver transistor turns fully on, and that the LED voltage is typical of a white LED, somewhere between 3.0 and 3.3V.

There are issues with these assumptions, and with driving four LEDs in parallel from one resistor. It will normally work, but there is a much higher risk of popping one, or all of them (due to thermal runaway of one over driven LED), if you drive them hard, than there would be if there were a current limiting resistor per LED.

Even if you are driving them with PWM, if the resistor value is too low, you still risk brown out of your PSU thus causing the LEDs to flicker and/or the CPU to crash. Also if you drive the voltage regulator too hard or cause the LEDs to start to break down by overheating you may release the magic smoke from both the LEDs and the regulator.

If you drive the LEDs without the transistor (using short On, long Off PWM pulses and a suitable single resistor), this may work, but you risk blowing up the GPIO pin if your chosen resistor allows more than the maximum GPIO current if the LED fails short circuit. :( You wont be able to drive them as hard, without the transistor of course.
I am also assuming four LEDs, there may only be two, in which case… we need to do the maths for two. :roll:

EDIT2: I have just spotted that whoever designed the actual display knew what they were doing, as they have brought out all four LED cathodes, to allow for four current limiting resistors. A much saner option than paralleling up all four LEDs, but the shield designer has cheaped out by wiring the cathodes together, thus limiting your option to only one current limiting resistor.

ahull Tue Oct 11, 2016 9:35 am

Interestingly that first screen with the display flipped over has a 2013 date code on it, I wonder what devices these are recovered from. I guess they could be “surplus” stock, but its more likely they come from a particularly popular consumer device, most probably a previous generation phone. Maybe I should ask my local phone repair shop if they recognise the screen. :D

konczakp Tue Oct 11, 2016 5:18 pm

I’ve just measured the current between resistor and tft led. Highest current I have seen is 25,33mA. Is that okey?

ahull Wed Oct 12, 2016 12:19 am

konczakp wrote:I’ve just measured the current between resistor and tft led. Highest current I have seen is 25,33mA. Is that okey?

konczakp Wed Oct 12, 2016 7:05 am

Screen is bright enough so I will stick to this 5 Ω. Thank You for Your help. I really appreciate that :)

Pito Wed Oct 12, 2016 8:47 am

Increasing current through the LEDs may not proportionally increase brightness
As the first LEDs appeared in seventies the rule was 20mA. They were all red, with Vf something like 1.6V and with 5V all used 150 to 200ohm.
Interestingly, the majority of designers especially of cheapo boards are following this 200ohm paradigm (or 10-20mA per LED), even today.
I did a measurement on about 20 various LEDs (mostly smd ones, all colors) from my junkbox to see how much current you need today in order to have an LED as “the indicator” of ON/OFF. The most LEDs are fine with 0.1mA for normal usage as indicator of a state. That leads to resistors of many kiloohms value. The clever designers adopted 1k resistors recently, but still the brightness is so high that in the ambient conditions you cannot see the buttons because of the brightness of the LEDs on the pcb :)
The LEDs differ significantly in the Vf and in If/brightness so the measurement is the only way to have an idea on the current vs. required brightness. If OP would experiment he sees the display works fine with maybe 10mA or less :)

ahull Wed Oct 12, 2016 9:15 am

When using the STM32 boards in battery operated projects, I usually remove the “Power On” LED (or its current limiting resistor, whichever is easiest to get at with the soldering iron), as it typically draws anything from 5mA to 25mA depending on which LEDs were cheap in the marked that day, and which resistors the manufacturer had already racked up in the pick and place machine. :D

This trick, coupled with low power modes on the CPU can extend the battery life from a few hours to weeks or even months.

Post a reply