Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 22 of 22

Thread: Problems with ILI9341 on Teensy 3.1

  1. #1
    Member
    Join Date
    Feb 2017
    Location
    A Coruņa, Spain
    Posts
    34

    Problems with ILI9341 on Teensy 3.1

    Good evening,

    I am trying to use the ILI9341 to display some data during the execution of my code, but my display shows nothing and the function "loop" is not executed.

    First of all I configure the pins DC, CS, SDO, SDI and SCK for the display and when I want to change the color of the screen to white with the function tft.fillScreen the code below this point is not executed.

    What am I doing wrong? May anybody help me with this problem?

    PINOUT
    Vcc-->5V
    GND->AGND
    CS-->10
    DC-->9
    SDI-->12
    SCK-->14
    SDO-->11
    LED-->5V via 100ohm resistor
    Reset-->3.3V

    CODE

    #include <ILI9341_t3.h>
    #include <SPI.h>
    #include <Wire.h>

    #define PIN_SCK 14
    #define PIN_SDI 12
    #define PIN_SDO 11
    #define PIN_CS 10
    #define PIN_DC 9
    #define RST 255
    #define ALTURA_LETRA 5

    ILI9341_t3 tft=ILI9341_t3(PIN_CS,PIN_DC,RST,PIN_SDI,PIN_SCK,P IN_SDO);



    void setup() {

    tft.begin();
    tft.fillScreen(ILI9341_WHITE);
    tft.setTextColor(ILI9341_BLUE);
    tft.setTextSize(ALTURA_LETRA);
    tft.setRotation(0);
    tft.setCursor(0,0);
    tft.println("Hola");


    }

    void loop() {

    Rest of the program....

    }

    CURRENT WIRING
    Click image for larger version. 

Name:	Archivo 9-4-17 12 15 15.jpg 
Views:	139 
Size:	84.4 KB 
ID:	10260

  2. #2
    i think your SCK needs to be on pin 13 (native SPI SCK).

  3. #3
    Member
    Join Date
    Feb 2017
    Location
    A Coruņa, Spain
    Posts
    34
    Hi,

    according with the info I can use pins 13 or 14 as SCK pin. I am using pin13 for other task however I changed pin 13-14 for the SCK and it doesn't work yet.

    I don't know what is going wrong here.

  4. #4
    Junior Member
    Join Date
    Mar 2017
    Location
    Colorado Springs, CO
    Posts
    13
    I was able to make it work with two minor changes. PIN_SDI should be pin 11 and PIN_SDO should be pin 12.

    Good luck.

  5. #5
    Member
    Join Date
    Feb 2017
    Location
    A Coruņa, Spain
    Posts
    34
    Hi,

    i changed the defines
    #define PIN_SDI 11
    #define PIN_SDO 12

    and the wiring, after these changes the whole code is running but on the display I can't see anything.

    I corrected an error but another left.

    Click image for larger version. 

Name:	Archivo 9-4-17 21 43 20.jpg 
Views:	48 
Size:	165.3 KB 
ID:	10261Click image for larger version. 

Name:	Archivo 9-4-17 21 43 20.jpg 
Views:	48 
Size:	165.3 KB 
ID:	10261

  6. #6
    Junior Member
    Join Date
    Mar 2017
    Location
    Colorado Springs, CO
    Posts
    13
    I am not sure of why it is not working for you. My LCD is wired per the pinout in this link: https://www.pjrc.com/store/display_ili9341.html

    Here is the your code that I changed and it is working for me. There was a minor error in the call to the display where I had to remove a space between the P and IN_SDO so it is now PIN_SDO.

    #include <ILI9341_t3.h>
    #include <SPI.h>
    #include <Wire.h>

    #define PIN_SCK 14
    #define PIN_SDI 11
    #define PIN_SDO 12
    #define PIN_CS 10
    #define PIN_DC 9
    #define RST 255
    #define ALTURA_LETRA 5

    ILI9341_t3 tft=ILI9341_t3(PIN_CS,PIN_DC,RST,PIN_SDI,PIN_SCK,P IN_SDO);



    void setup() {

    tft.begin();
    tft.fillScreen(ILI9341_WHITE);
    tft.setTextColor(ILI9341_BLUE);
    tft.setTextSize(ALTURA_LETRA);
    tft.setRotation(0);
    tft.setCursor(0,0);
    tft.println("Hola");


    }

    void loop() {

    //Rest of the program....

    }

    Hope this helps. If this does not work for you, I would suggest you verify your wiring connections are the same as shown in the wiring diagram in the link above.

  7. #7
    Member
    Join Date
    Feb 2017
    Location
    A Coruņa, Spain
    Posts
    34
    I rewire the display the same as in the link and I have the same problem.... I couldn't see anything....

    May the screen be damaged? How can I check if the screen is ok?

  8. #8
    Junior Member
    Join Date
    Mar 2017
    Location
    Colorado Springs, CO
    Posts
    13
    My best suggestion is to test the code using a different display. This is why I have one display like this and two of the newer displays with the touch screen. If you do not have another display, then I am not sure of how to test to see if the display is OK.

    Sorry you are not getting this to work.

  9. #9
    Member
    Join Date
    Feb 2017
    Location
    A Coruņa, Spain
    Posts
    34
    Hi,

    finally I restarted all and the display started to work!!!

    Only one more question... If I want to change the text between horizontal/vertical, what have I to do?

    Thanks for the help.


    Click image for larger version. 

Name:	Archivo 9-4-17 22 42 17.jpg 
Views:	54 
Size:	78.2 KB 
ID:	10262

  10. #10
    Junior Member
    Join Date
    Mar 2017
    Location
    Colorado Springs, CO
    Posts
    13
    Glad you got it working. I really like this display and I am now using the touch version as my standard display.

    Use the setRotation(value) command with the value being 0, 1, 2, or 3. Each value will rotate the text by 90 degrees.

    tft.setRotation(3);

    Have fun!

  11. #11
    Member
    Join Date
    Feb 2017
    Location
    A Coruņa, Spain
    Posts
    34
    An easy new question. I read two analog values each 20ms and I want to display these two values (0-1023) but after one minute I have a chaos on the screen.
    How can I update these values without overwriting the letter on the screen?
    Maybe a command as clear screen or so before "printing"?


    tft.setScroll(25);
    tft.print("ADC1 = ");
    tft.println(adc1);

    tft.print("ADC2 = ");
    tft.println(adc2);

  12. #12
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,454
    So it works and scrolls down as desired 50 times per second and all goes well for one minute? Then what 'chaos' do you see?

  13. #13
    Member
    Join Date
    Feb 2017
    Location
    A Coruņa, Spain
    Posts
    34
    After a minute I can't see anything because the letters are overwriting without deleting the old values....

    In my first code I am sending the data to the screen each 40ms but the time is not important for this application. A refresh of 1s is good enough.

    My point is how can I refresh the values on the screen and delete the old ones?

    I have no image right now to upload

  14. #14
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,464
    There are many ways of doing this. One is you could erase the area before you write the next line... But pain.

    Have you tried Opaque text? That is in your initial code:
    Code:
    tft.begin();
    tft.fillScreen(ILI9341_WHITE);
    tft.setTextColor(ILI9341_BLUE, ILI9341_WHITE);  // Set both FG and BG colors.
    This will setup that when you write out the characters, the parts that are not set to BLUE will be set to white.

    This should get you mostly there. However if the length of strings change, the new string only writes as much as it needs to, so could be characters that are not overwritten.

    Note: I typically have not used the Scroll stuff, but instead set the Text position explicitly for each main field.

    A couple ways to handle the maybe does not overwrite all of the characters... May depend on if anything displays right to right of the field and if I have room. But suppose the value you output is from 1-3 characters in length and I have room, I can get lazy and do something like:
    Code:
    tft.print("ADC1 = ");
    tft.print(adc1);
    tft.println("  ");
    
    tft.print("ADC2 = ");
    tft.print(adc2); 
    tft.println("  ");
    If I don't have room and wish to avoid flicker, I do something like:
    Code:
    tft.setCursor(100, 100); // assume your field starts at 100, 100 and goes to 200, 150
    tft.print("ADC1 = ");
    tft.print(adc1);              // you finished your output of the field. 
    tft.getCursor(&x, &y);   // get the current text position x, y are defined as int16_t
    tft.fillRect(x, 100, 200, 150, ILI9341_WHITE);  // fill in the rest of the area with white.
    The height of the fill above depends on the font size and the like. I would have to look but it is something like 8*size.
    You can also do fancy things like remember the ending X for the previous write and only fill up to that width... But maybe more trouble than it is worth.

    Good Luck

  15. #15
    Member
    Join Date
    Feb 2017
    Location
    A Coruņa, Spain
    Posts
    34
    Hi,

    I tried to draw a white rectangle to "cover" the text but I can see the blink, how can I draw faster?

  16. #16
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,464
    Helps to see the code... If you simply fillrect over the area and then draw text, then you will most likely see a flash.

    There has been talk about this on several threads including: https://forum.pjrc.com/threads/26305...l=1#post112355

  17. #17
    Member
    Join Date
    Feb 2017
    Location
    A Coruņa, Spain
    Posts
    34
    I simply wrote tft.fillRect(0, 0, 1000, 1000, ILI9341_WHITE); to clear all the display

  18. #18
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    8,464
    Quote Originally Posted by Borja View Post
    I simply wrote tft.fillRect(0, 0, 1000, 1000, ILI9341_WHITE); to clear all the display
    Well it does exactly what you see! M posting (#14) showed a couple ways to not have the flash).

    I would recommend first trying out the Opaque text to see how that works for you.

  19. #19

    ILI9341 - No Display

    I'm running the code below on a Teensy 3.2, and a PJRC ILI9341 color display board with the recommended Osh Park "purple board". All I get is a white (blank) screen. The main loop seems to be running, as indicated by the print. Any suggestions?

    #include <ILI9341_t3.h>
    #include <SPI.h>
    #include <Wire.h>

    #define PIN_SCK 13
    #define PIN_SDI 11
    #define PIN_SDO 12
    #define PIN_CS 10
    #define PIN_DC 9
    #define RST 255
    #define ALTURA_LETRA 5

    ILI9341_t3 tft=ILI9341_t3(PIN_CS, PIN_DC, RST, PIN_SDI, PIN_SCK, PIN_SDO);



    void setup() {

    tft.begin();
    tft.fillScreen(ILI9341_WHITE);
    tft.setTextColor(ILI9341_BLUE);
    tft.setTextSize(ALTURA_LETRA);
    tft.setRotation(0);
    tft.setCursor(0,0);
    tft.println("Hola");
    Serial.begin(9600);

    }

    void loop() {

    //Rest of the program....
    Serial.println("looping");
    }
    Last edited by joedarock; 04-18-2017 at 07:28 PM.

  20. #20
    Junior Member
    Join Date
    Mar 2017
    Location
    Colorado Springs, CO
    Posts
    13
    Your code runs perfectly on my development system. My guess there is a problem in the interface between your display and the T3.2. I do not use one of the Osh Park PCBs but have made my own hardwired interface connected per the pinout that has been published for that display. Because the screen is white, I take it that the display is getting power.

    Good luck with your troubleshooting.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	IMG_1456.JPG 
Views:	42 
Size:	43.0 KB 
ID:	10333  

  21. #21
    Thanks

    I wanted to look at the schematic of the interface board to see how the I/O is mapped from the Teensy to the display, but there apparently is no such document. Guess I'll have to buzz it out with an ohmeter.

    Joe

  22. #22
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,454
    IIRC - The wiring on the OSH Purple test board matches that on the Store page for the ILI9341 where it is linked. When I had one ALL WHITE it was resolved using other link on that page - closing jumper J1 to bypass the onboard voltage regulator - when using only 3.3V.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •