STM32H743 FMC with ST7789 doesn't work without delay
I have an STM32H743 connected to a screen that uses ST7789 via FMC (i.e. parallel connection) using 8-bit bandwidth and A18 to select between command and data.
The current code has an issue that the screen output is messed up (see pictures below) if I don't add a sleep to my write functions that uses FMC.
The code is working (no need for delay) under STM32CubeIDE but I ported it to work as part of MicroPython.
Things that I already considered:
- Python speed - The code in C is a nested for loop and calls writeData so it isn't a python speed thing.
- System clock/FMC - I copied the whole code of FMC initialization (including Msp), GPIO and systemclock to MicroPYthon without any fix.
- HAL version - MicroPython uses a different stm32 HAL version but I copied the SRAM/FMC files and it still didn't work
Any pointer on what might be the issue? Is it a FMC clock configuration? some configuration on external memory location?
Any config that slows down the FMC as RAM access
Appendix:
#define COMMAND_LOCATION 0xC0000000
#define DATA_LOCATION 0xC0040000
static uint8_t* fmc_command_pointer = (uint8_t*) COMMAND_LOCATION;
static uint8_t* fmc_data_pointer = (uint8_t*) DATA_LOCATION;
void writeCommand(uint8_t command)
{
*fmc_command_pointer = command;
HAL_Delay(100);
}
//*****************************************************************************
void writeData(uint8_t data)
{
*fmc_data_pointer = data;
HAL_Delay(1);
}Filling the screen with the color blue without the delay in writeData produces:
With the delay (after a while since it takes 1ms per pixel) fills it correctly:
