I am big fan of the Discovery boards and whenever I buy a new one I try to configure it using CubeMX.
As you know the provided examples are NOT generated by the CubeMX and there is no CobeMX project files available.
So you need to create project file by yourself.
This time I bought STM32F412G-DISCO and tried to reverse engineer the BSP driver to understand what setting should be selected in CubeMX do generate the same FSMC settings as seen in BSP driver.
The stm32412g_discovery.c contains the following code snipped related to FSMC:
* @brief Initializes LCD IO.
static void FMC_BANK1_Init(void)
/*** Configure the SRAM Bank 1 ***/
/* Configure IPs */
hsram.Instance = FSMC_NORSRAM_DEVICE;
hsram.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
/* Timing for READING */
sram_timing.AddressSetupTime = 9;
sram_timing.AddressHoldTime = 1;
sram_timing.DataSetupTime = 36;
sram_timing.BusTurnAroundDuration = 1;
sram_timing.CLKDivision = 2;
sram_timing.DataLatency = 2;
sram_timing.AccessMode = FSMC_ACCESS_MODE_A;
/* Timing for WRITTING*/
sram_timing_write.AddressSetupTime = 1;
sram_timing_write.AddressHoldTime = 1;
sram_timing_write.DataSetupTime = 7;
sram_timing_write.BusTurnAroundDuration = 0;
sram_timing_write.CLKDivision = 2;
sram_timing_write.DataLatency = 2;
sram_timing_write.AccessMode = FSMC_ACCESS_MODE_A;
hsram.Init.NSBank = FSMC_NORSRAM_BANK1;
hsram.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE;
hsram.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM;
hsram.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16;
hsram.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE;
hsram.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;
hsram.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;
hsram.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS;
hsram.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE;
hsram.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE;
hsram.Init.ExtendedMode = FSMC_EXTENDED_MODE_ENABLE;
hsram.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
hsram.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
hsram.Init.WriteFifo = FSMC_WRITE_FIFO_DISABLE;
hsram.Init.PageSize = FSMC_PAGE_SIZE_NONE;
hsram.Init.ContinuousClock = FSMC_CONTINUOUS_CLOCK_SYNC_ONLY;
/* Initialize the SRAM controller */
HAL_SRAM_Init(&hsram, &sram_timing, &sram_timing_write);
I would like to learn what should be selected in CubeMX to have the same setting automatically generated.
My suggestion to the ST Team:
Could you please provide EITHER CubeMX project file to Discovery boards OR please provide exact setting which can be used when someone would like to create the CubeMX project from the scratch.
Othewise I need to reverse engineer the BSP drivers to learn what I2C/SPI pheripheral to use. This is easy. But whenever I try to use LCD controller it takes much more time.
I was able to do it STM32F429-DISCO for example but I cannot do it for STMF412FDISCO.
Thanks in advance,