Skip to main content
Explorer
July 7, 2024
Solved

My LCD works ok on SPI2 Discovery F407, the same LCD does not work on SPI1 on a F405 custom pcb

  • July 7, 2024
  • 3 replies
  • 3837 views

So as the subject says, my LCD works correctly when attached to my F407 Discovery board and using SPI2.

I am now using a F405 and SPI1 on a custom PCB. I have configured the SPI1 the same as SPI2, basically copied the settings.

However I need some advice on the clock speeds and settings. When I use the LCD on the discovery board it will run at low speeds - 10MHz.

For SPI1 ton the F405, the maximum speed is lower at 42MHz. Which clocks do I need to set and what speeds do I need for each clock?

Using an oscilloscope reveals that I am gettting signals from the MCU on all the relevent pins. My guess is a timing issue of some sort......

I know that the MCU is functioning correctly, flashing programs and debug work as normal.

Any suggestions or help much appreciated. Thanks in advance

    This topic has been closed for replies.
    Best answer by waclawek.jan

    Maybe it's time to look at all the signals at once (and directly at the display) using logic analyzer, and compare the waveforms with the working case and/or display's controller's datasheet.

    At the end of the day, you can also bit-bang the interface, and such software should be easily transferrable from the Disco to your hardware.

    And you don't need to be focused solely on the SPI-related software. Things like ground/signal-return arrangement (i.e. separate return for each signal, signal wires mutually isolated by the ground/returns, short cables); power supply stability and sequencing; reset - these all matter, too.

    JW

    3 replies

    Graduate II
    July 7, 2024

    Displays dont use only SPI , but more control signals . Show schematic and code . From your explain only speed config = setupHSE or HSI and PLL, when you use CubeMX set clock config to max.

    Explorer
    July 7, 2024

    PinOut F405:

    SPI MOSI - PA7

    SPI CLK- PA5

    LCD_DC - PA6

    LCD_RST- PC4

    Code: see attached file

    IOC setup: see attached picture

    Im using an external crystal at 8Mhz

     

    Graduate II
    July 7, 2024

    Typically you clock APB2 at least as fast as APB1. I don't know this will cause a clock-inversion issue, but would perhaps be worth checking if doing Memory-to-Memory with DMA2

     

    If at 40 MHz would need to prescale in the SPI peripheral to get 10 MHz externally.

    10.5 MHz might be too fast for the display, although there might be some margin. I'd start with 5.25 MHz, or clock the MCU at a lower rate to get the gearing needed.

    Graduate II
    July 7, 2024

    What SPI Display? Cite Make/Model, and link to specs.

    SystemClock_Config(); will determine your MCU speed, that of the AHB which connects to things external to the core (CM4F), and the APB1 (lower speed) and APB2 (higher speed) peripheral buses.

    Which SPI will determine which APB is in use. The SPI Prescaler in the peripheral itself will determine how the APB clock divides down to get to the SPI CLOCK (SPI1_SCK) to the external device.

    SPI1 on the STM32F4 is on APB2, you're clocking this at what speed?

    Explorer
    July 7, 2024

    It is LCD TFT without touch. It uses the ILI9341 chipset. Note I have this working fine on the discovery board.

    It will run fine at speeds 10-72MHz.

    See the picture of IOC in previous post

    Graduate II
    July 7, 2024

    Specs for the ILI9341 say maximum of 6.6 MHz for READ, and 10 MHz for WRITE

    Divide the SPI's peripheral clock to meet the device's specification.

    Super User
    July 7, 2024

    Maybe it's time to look at all the signals at once (and directly at the display) using logic analyzer, and compare the waveforms with the working case and/or display's controller's datasheet.

    At the end of the day, you can also bit-bang the interface, and such software should be easily transferrable from the Disco to your hardware.

    And you don't need to be focused solely on the SPI-related software. Things like ground/signal-return arrangement (i.e. separate return for each signal, signal wires mutually isolated by the ground/returns, short cables); power supply stability and sequencing; reset - these all matter, too.

    JW

    Explorer
    July 7, 2024

    A good suggestion. I will have a go at this tomorrow. Thanks

    Explorer
    July 8, 2024

    So after some use of the oscilloscope I could see that the SPI clock and MOSI were writing the correct byte values for initilisation of the LCD. When it came to writing a buffer I noticed that my DC pin was not going high. When I reviewed the code I could see that the wrong port was specified. I changed it to the correct port and bingo, we are working!

    Learning for me:

    1) Never assume that a library you found off the net is coded properly.

    2) Always look at the obvious things first.

    3) Dont come on here wasting time before checking all the above.

    All said and done this little saga will no doubt be of use in terms of learning for somone else, hopefully!