Skip to main content
Harry May
Associate
September 17, 2017
Question

FMC Bug in CubeMX

  • September 17, 2017
  • 2 replies
  • 789 views
Posted on September 18, 2017 at 01:42

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

    This topic has been closed for replies.

    2 replies

    ST Technical Moderator
    September 18, 2017
    Posted on September 18, 2017 at 18:30

    Hello

    harry4516

    ,

    Itested with the same board and CubeMX version (4.1):The

    FMC clock is enabled and the

    GPIOs are initialized in STM32F4xx_hal_msp.c file.

    Please, try to share your ioc file to check your issue.

    0690X00000608HnQAI.png

    Kind Regards

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Harry May
    Harry MayAuthor
    Associate
    September 18, 2017
    Posted on September 18, 2017 at 22:26

    Hello Imen,

    thank you for answering.

    How to reproduce the problem:

    In CubeMX 4.22.1: New Project, select STM32F427VG, Start Project

    Configure: FMC for LCD, A16, 16bit

    Configure: RRC enable ext Clock

    Generate program. This is all I have done.

    If I look into STM32F4xx_hal_msp.c then I see no Clock or GPIO init, only Priority settings.

    I have put the files on my server:

    ioc-File:

    http://www.dj0abr.de/files/fmctest.ioc

    complete project as ZIP:

    http://www.dj0abr.de/files/fmctest.zip

    Kind Regards

    Harry