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

Thread: How to slow down SPI clock for Adafruit-ST7735 library ?

  1. #1
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    106

    How to slow down SPI clock for Adafruit-ST7735 library ?

    I'm trying to use Adafruit 240x240 TFT LCD https://www.adafruit.com/product/3787

    With their library
    https://github.com/adafruit/Adafruit-ST7735-Library
    https://github.com/adafruit/Adafruit-GFX-Library

    On a Teensy 4.0

    The demo software works on their pre July 24, 2019 unit but not on the new unit. The new board has an extra TE pin. That is just an output pin.

    The default SPI clock speed is 12MHz as measured on a scope. I want to slow this down a bit to see if the new units works but can't find the place where the SPI clock speed is set.

    I've tried to change value in:

    Adafruit-ST7735 library
    Adafruit_ST77xx.cpp
    #define SPI_DEFAULT_FREQ 32000000 ///< Default SPI data clock frequency

    but that didn't change the SPI clock speed.

    Then I tried to change the value in:

    Adafruit_GFX library
    Adafruit_SPITFT.h
    #define DEFAULT_SPI_FREQ 1000000L ///< Hardware SPI default speed

    That didn't change the SPI clock either.

    So the question is where can I change the SPI clock speed ?

  2. #2
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    4,810
    @skpang
    Haven't really used the Adafruit library so no sure. But have you tried the ST7735_t3 library that is installed with Teensyduino. SPI Clock is set in one place, ST7735_t3.h, right at the beginning.

  3. #3
    Senior Member
    Join Date
    Jan 2015
    Location
    UK
    Posts
    106
    Wow ST7735_t3 works without changing anything. I see the SPI clock is at 24MHz and it works. Not sure why I used Adafruit's one in the first place.

    Many thanks.

  4. #4
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,347
    A couple of things to maybe check.

    First is which Adafruit library you are actually running.

    Why I mention this, is there are actually two different ones from Adafruit. The newer one I believe shows up saying something like ST7735 and ST7789.

    So you may want to make sure you are actually building with the version you think you are. You might verify this by enable of verbose compiles in preferences) and check the diagnostics output, like it might say multiple libraries found for xxx (like ST7735) and this one is used and this one is not... Make sure it is the one you are trying to edit.

    I ended up removing the old one and installing the newer one, especially when I started also playing with the ST7789 displays. And their support for any new display maybe only in the newer one.
    Looks like the github one you linked to is the newer one: https://github.com/adafruit/Adafruit-ST7735-Library

    Again assuming you are compiling the one you think you are:
    The setting you mentioned in Adafruit_ST77xx.cpp should be the correct one.


    #define SPI_DEFAULT_FREQ 32000000 ///< Default SPI data clock frequency

    Note: the device you are using is an ST7789, which I have used.

    Note most of the time I use our own library st7735_t3 which ships with Teensyduino and support st7789 as well.

    EDIT: Looks like I was a little late on response...

  5. #5
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,540
    One other thing, some of the Adafruit displays need pull-up resistors on the CS pins. I had a setup with 2 displays (the uncanny eye project at Adafruit), and I always had problems with corruption on the screen, until I lowered the SPI clock frequency. When I added 2.2K pull-up resistors to each of the CS pins (and maybe the D/C pin), I was able to bump the SPI speed much higher. The idea comes from this paper on optimizing the SPI bus:

Posting Permissions

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