cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F412G-DISCO - how to configure FSMC using CubeMX

Posted on June 08, 2017 at 21:17

Hi,

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)

{  

  SRAM_HandleTypeDef hsram;

  FMC_NORSRAM_TimingTypeDef sram_timing;

  FMC_NORSRAM_TimingTypeDef sram_timing_write;

  /*** 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 */

  FMC_BANK1_MspInit();

  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.

0690X00000602UnQAI.bmp

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,

Bogdan

2 REPLIES 2
Posted on June 13, 2017 at 06:52

Hi,

For someone who is interested in.

I tried again and concluded that the following setting to bring up LCD alive are as follows:

0690X00000607JdQAI.png

Now you can call BSP_LCD_Init() and subsequent API to select colors and put text/graphic on the display.

=====

Now I am going to enable TS which still does not work.

I enabled I2C1 (shared with audio chip), and PD5 to trigger interrupts (falling edge) but BSP_TS_init() returns an error.

Need to investigate it.

Bogdan

PS. In mean time I enabled the STM32F746 DISCO both LCD and TS without any problems. Works perfectly.

Posted on June 13, 2017 at 17:49

I also managed to use the Touch Screen - the reset pin (CTP_RST_Pin) was wrongly set to RESET value.

So all works fine  - the CubeMX can generate right drivers.