AnsweredAssumed Answered

FMC Bug in CubeMX

Question asked by Harry May on Sep 18, 2017
Latest reply on Sep 18, 2017 by Harry May

Hello,

CubeMX is missing some lines of code, so the FMC will not work with the generated code.

 

CubeMX Version: 4.22.1

CPU: SMT32F427VG..

 

First I configured the FMC for my TFT display with the standard libs and all worked fine.

Then I used CubeMX to generate the same code using HAL.

In general the code is correct, but two important things are missing in MX_FMC_Init():

 

1. at the beginning the FMC clock must be enabled: __HAL_RCC_FMC_CLK_ENABLE();

2. the GPIOs of the FMCs are not initialized as alternate function, so I added:

 

    GPIO_InitTypeDef GPIO_Init_Structure;
    GPIO_Init_Structure.Mode      = GPIO_MODE_AF_PP;
    GPIO_Init_Structure.Pull      = GPIO_NOPULL;
    GPIO_Init_Structure.Speed     = GPIO_SPEED_HIGH;
    GPIO_Init_Structure.Alternate = GPIO_AF12_FMC;

 

    GPIO_Init_Structure.Pin   = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_4 | GPIO_PIN_5 |
                                  GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |
                                  GPIO_PIN_14 | GPIO_PIN_15;
    HAL_GPIO_Init(GPIOD, &GPIO_Init_Structure);

 

    GPIO_Init_Structure.Pin   =   GPIO_PIN_7 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 |
                                  GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
    HAL_GPIO_Init(GPIOE, &GPIO_Init_Structure);

 

with this additional code everything works perfectly.

 

Maybe one of the CubeMX programmers can look at this issue and add this code into the automatic program generator.

 

Harry

Outcomes