cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F767ZI FMC LCD initialization is failing and calling MemManage_Handler()

EasyNet
Associate II

Post edited by ST moderator to be inline with the community rules for the code sharing. In next time please use </> button to paste your code and a linker script content. Please read this post: How to insert source code.

Hello,
I'm trying to use an LCD with ILI9341 chip. I've connected all pins to the LCD and I've set in CubeMX the FMC like this:

EasyNet_0-1765826264263.png

But when I tried to run the program, all calls from main.c is calling MX_FMC_Init(); then is going in this function:

HAL_StatusTypeDef FMC_NORSRAM_Init(FMC_NORSRAM_TypeDef *Device,
const FMC_NORSRAM_InitTypeDef *Init)
{

..

__FMC_NORSRAM_DISABLE(Device, Init->NSBank);

..

And soon this macro is executed function MemManage_Handler() is called:


/**
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
SerialPrint("MemManager_Handler fault..");

/* USER CODE END MemoryManagement_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
/* USER CODE END W1_MemoryManagement_IRQn 0 */
}
}

And I can't go over this error. I don't understand what is wrong with the FMC configuration.

Can somebody give me a help?

1 REPLY 1
mƎALLEm
ST Employee

Hello,

Most probably you have the MPU default configuration enabled which disables the access to all external memory regions:

static void MPU_Config(void)
{
  MPU_Region_InitTypeDef MPU_InitStruct;

  /* Disable the MPU */
  HAL_MPU_Disable();

  /* Configure the MPU as Strongly ordered for not defined regions */
  MPU_InitStruct.Enable = MPU_REGION_ENABLE;
  MPU_InitStruct.BaseAddress = 0x00;
  MPU_InitStruct.Size = MPU_REGION_SIZE_4GB;
  MPU_InitStruct.AccessPermission = MPU_REGION_NO_ACCESS;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
  MPU_InitStruct.Number = MPU_REGION_NUMBER0;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
  MPU_InitStruct.SubRegionDisable = 0x87;
  MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;

  HAL_MPU_ConfigRegion(&MPU_InitStruct);

  /* Enable the MPU */
  HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}

That default MPU configuration is to prevent the CM7 speculative access to the non configured memories especially the external ones (explanation here). So you need to configure another MPU memory region to enable the access to the LCD.

Hope that helps.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.