cancel
Showing results for 
Search instead for 
Did you mean: 

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

TombrownBottom
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

15 REPLIES 15
MM..1
Chief II

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.

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

 

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?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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

I am running DMA, but I dont know how this works from technical perspective.

How do I check for clock inversion? Why would it do this. Shouldnt the IOC setup take of this?

It probably should, but apparently doesn't. It's akin to running water uphill, the design internally has other expectations, or you need resynchronizers to move into a slower clock domain.

There are ratio issues for using USB, SDIO, CRYP, DCMI

You should use the PRESCALER in the SPI peripheral to accommodate the maximum rate of the attached device.

SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4; // 2 to 256

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thats stange I had the clock speed up at 72MHz on the dicovery board SPI2. It worked fine.

 

I will try turn the speed down and come back to you.