Hi all!
I work with ILI9341 based 2.8" LCD (see link at the end of the post)
True is, I do not use an Arduino board but STM32L0 device, but I think my problem is not MCU specific (I hope so).
Think is, before I try to modify any library to bend it for the STM32L0 I wanted simply to check my SPI configuration by issuing a simpliest thing, reading LCD ID registers. But that's the thing, I do not receive any data from ILI9341. I guess all registers are accessible right after the proper reset of the ILI9341, right? So, here is my "init" procedure:
- necessary HW init(GPIO, SPI, CLOCKs...)
- pull RST pin down
- wait 100 ms
- pull RST pin up
- wait 100 ms
-send 0x04 CMD with DC pin down and try to catch the response with DC pin up.
please, see attached screen from my logic analyzer. You can see, CS is brrought low followed by eight clock pulses (500 kHz period) on SCK and 0x04 MSB first on the MOSI and with the DC set low. Afterwards, there is sequence of 4 dummy 0xFF bytes to push out the desired data out from the ILI9341 SPI buffer with the DC set high. But as you can see, there are only zeros on MISO line. Of course, the CS is brought up at the end. I've checked the wiring 10 times and I don't think it is the problem. Maybe, are really all register accessible right after the start of the ILI9341? Or do I have to wirte some data somewhere first?
Thanks a lot for any feedback guys
onbartik
LCD:
Post a link to the actual STM32 board that you are using.
And show your wiring to the ILI9341 board.
Regular ILI9341 libraries should work just fine with the official STM32 Core from STMicroelectronics
I have used with F072, F103, F401, F411, F446, L476, ...
David.
Hi David,
thanks you for replay and I am sorry but I was off for the weekend. Well, I attached two pictures of the connection at the and of this post, but honestly, there is not much to see there. There is no hand made soldering, everything is factory made. But one can check the right cable placement by cable coloros from these pictures. The STM32 device is STM32L031K6T6 sitting on STM32L031K6-nucleo board.
connections are as follows:
CSN is pin PA4 on STM32 ( pin A3 on nucleo) - blue cable
SCK is pin PA5 on STM32 ( pin A4 on nucleo) - green cable
MISO is pin PA6 on STM32 ( pin A5 on nucleo) and it is connected to display MOSI - yellow cable
MOSI is pin PA7 on STM32 ( pin A6 on nucleo) and it is connected to display MISO - orange cable
DE is pin PA3 on STM32 ( pin A2 on nucleo) - violet cable
RST is pin PA1 on STM32 ( pin A1 on nucleo) - gray cable
The brown loose cable is from the LED control. Not important for SPI communication. The red and black cables are connected to 3.3V and GND respectively.
I have connected different SPI device (NRF24L01+) with the same cable placement (apart from DE and RST) and communication works fine.
Thanks for any feedback
P.S. here is link to board user guide to check the pins (page 22) if you like:
https://www.st.com/resource/en/user_manual/dm00231744-stm32-nucleo32-boards-mb1180-stmicroelectronics.pdf
Why is there a jumper between D2 and GND ?
I would either use Bodmer's TFT_eSPI library examples. You have to check/create a suitable User_Setup file
Or use Adafruit libraries with the appropriate constructor e.g.
Adafruit_ILI9341 tft(A3, A2, A1); //Arduino pin names
Or use CPU names
Adafruit_ILI9341 tft(PA4, PA3, PA1); //Arduino port names
David.
Well David, the jumper is there cause of the factory blinking example. It is there when you purchase this board. LED blinking has different freq with and without the jumper placed. I just left it there. It has no function.
Anyway, I've noticed interesting fact. Thus, I need to swtich the MOSI/MISO. Originally I thought that MOSI and MISO on the display are display's MISO and MOSI :). But no, they are not. Mark MOSI on display is display's SDI and mark MISO on display is DSO. That means I need to plug MOSI to MOSI and MISO to MISO. Still no change with command 0x04 - Read Display ID. But when I issue cmd 0x09 - Read Display status I can get 0x00, 0x30, 0x80, 0x00 and 0x00. Which is finally something :). But according to datasheet, the most significant bit in third parameter (byte) should always be zero. I'm little bit confused. And also, when I issue 0xA (Read Display power mode) I get first byte (which should be XX..X) equal to 0x80 and the following one is zero. Does this ring any bells to you?
Thanks for your replay
MOSI means MasterOutSlaveIn
The ILI9341 is a Slave. So you connect MOSI to DIN. And MISO to DOUT.
Don't worry about the register reading for the moment.
Does the display show the graphics now ?
I have only used Nucleo-64 and Nucleo-144.
The ST Core assigns Arduino Digital and Analog pins correctly on those boards.
If in doubt, change CS, DC, RST to digital pins i.e. wiring and constructor
David.
Finally I got it! From LCD wiki:
http://www.lcdwiki.com/2.8inch_SPI_Module_ILI9341_SKU:MSP2807
I downloaded the example for STM32 and 'stole' the init sequence, which is slightly different than adafruit one or than this one:
https://vivonomicon.com/2018/06/17/drawing-to-a-small-tft-display-the-ili9341-and-stm32/
and it finally works! For now, I am able to fill the screen with solid color, but that is the milestone I needed to cross.
Thanks for all yours advices David
Seriously, I suggest that you stick with either TFT_eSPI or Adafruit_ILI9341.
I have used both with STM32 targets. TFT_eSPI will use DMA on most STM32 and give much better performance than Adafruit.
But the most important thing is that both libraries use intuitive Graphics methods.
LCDWIKI just does badly spelled incomprehensible methods.
Your STM32 site shows how to do the bare-metal STM32 code. Useful, but the Arduino STM32 Core does this for you.
David.
I have used the ili9341 OLED display also and managed to get it working after solving a few issues.
I created an security alarm that utilizes a google maps satellite picture that I shrink down to 320x240 using MS-Paint to fit the 3.2" display (but I have used this same fix on smaller SPI displays). I have also utilized an HC-12 transceiver to send and receive an alarm tripped by a PIR detector but that is out of the scope of this reply.
The cool thing about these displays is that they come with a SD memory slot and so once all the physical connections have been made to this display (many articles on connections so I won't go over those here) the most important thing I found is the timing which is done through the Chip Select Lines (CS). If the CS timing is not done correctly all you will see is the white back lite on the display and no image. The solution is to bring CS high just before you start reading the SD memory card, then take that memory CS low and then immediately bring the ili9341 display CS high. If this logic is not implemented in your program then this display will not work.
The only problem I am having with this display is that I have not been able to print text on top of a graphic image even though I tried several examples I found on the web utilizing different text libraries. Maybe someone has some good suggestions for that? I have been able to print text alone but when I try to print text over a graphics image it does not seem to work. Please only replies from people who have done this successfully.
the most important thing I found is the timing which is done through the Chip Select Lines (CS). If the CS timing is not done correctly all you will see is the white back lite on the display and no image. The solution is to bring CS high just before you start reading the SD memory card, then take that memory CS low and then immediately bring the ili9341 display CS high. If this logic is not implemented in your program then this display will not work.
And the Moon is made from green cheese !!
David.