2025-04-01 5:34 AM
Hi,
I am trying to interface Stm32h745 controller with a 240x320 TFT LCD over FMC. Interesting thing is, when I manually control lcd control and data pins(Set them as GPIO_OUTPUT_PP), Lcd works, but when I switched to FMC it does not. Tried lots of timing configuration but it did not help.
Here is the init for FMC
.Instance = FMC_NORSRAM_DEVICE;
.Extended = FMC_NORSRAM_EXTENDED_DEVICE;
.Init.NSBank = FMC_NORSRAM_BANK1;
.Init.DataAddressMux = FMC_DATA_ADDRESS_MUX_DISABLE;
.Init.MemoryType = FMC_MEMORY_TYPE_SRAM;
.Init.MemoryDataWidth = FMC_NORSRAM_MEM_BUS_WIDTH_8;
.Init.BurstAccessMode = FMC_BURST_ACCESS_MODE_DISABLE;
.Init.WaitSignalPolarity = FMC_WAIT_SIGNAL_POLARITY_LOW;
.Init.WaitSignalActive = FMC_WAIT_TIMING_BEFORE_WS;
.Init.WriteOperation = FMC_WRITE_OPERATION_ENABLE;
.Init.WaitSignal = FMC_WAIT_SIGNAL_DISABLE;
.Init.ExtendedMode = FMC_EXTENDED_MODE_DISABLE;
.Init.AsynchronousWait = FMC_ASYNCHRONOUS_WAIT_DISABLE;
.Init.WriteBurst = FMC_WRITE_BURST_DISABLE;
.Init.ContinuousClock = FMC_CONTINUOUS_CLOCK_SYNC_ONLY;
.Init.WriteFifo = FMC_WRITE_FIFO_DISABLE;
instance->deviceHandleAsRam.Init.PageSize = FMC_PAGE_SIZE_NONE;
FMC_NORSRAM_TimingTypeDef Timing = {0};
Timing.AddressSetupTime = 15; // 1 cycle = 16.67 ns
Timing.AddressHoldTime = 15; // 1 cycle hold time
Timing.DataSetupTime = 255; // 4 cycles ≈ 66.7 ns
Timing.BusTurnAroundDuration = 15;
Timing.CLKDivision = 16; // Unused in SRAM mode
Timing.DataLatency = 17; // Not used in mode A
Timing.AccessMode = FMC_ACCESS_MODE_A;
instance->deviceTiming = Timing;
Tried FMC peripheral clk from 240 Mhz down to 15Mhz
LCD command/data selection connected to A0, and I am bank swapping from0x60000000 to 0xC0000000
#define LCD_BASE_ADDRESS ((uint32_t)0xC0000000)
#define Lcd_CmdWrite(cmd) *((__IO uint8_t*)LCD_BASE_ADDRESS) = cmd
#define Lcd_DataWrite(data) *((__IO uint8_t*)((LCD_BASE_ADDRESS) + (1 << (0 + 1)))) = data
Here is the Logic Analyzer screen for 160Mhz Fmc Clock for the sequence below
And here is the same saquence output with manual GPIO Control
Thanks for any help