In your EE_Init(), when accessing FLASH_SIZE macro and you have ICACHE enabled in your project, hardfault is triggered.
Valid for at least for my H563ZI.
Possible solutions:
- I must call HAL_ICACHE_Disable(); HAL_ICACHE_Enable(); before and after my EEPROM access in my code.
- Use this code before using EEPROM access.
void MPU_Config(void) {
HAL_MPU_Disable();
// configure the MPU to prohibit access to after the .bss
// this will trigger an exception if the stack grows to large
MPU_Region_InitTypeDef MPU_InitStruct;
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER0;
MPU_InitStruct.BaseAddress = 0x08fff800;
MPU_InitStruct.LimitAddress = 0x08fff900;
MPU_InitStruct.AttributesIndex = MPU_ATTRIBUTES_NUMBER0;
MPU_InitStruct.AccessPermission = MPU_REGION_ALL_RO;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_DISABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_OUTER_SHAREABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}
- Or fix it in ee.c file directly :)
Do not understand why you didn't call here
#ifdef HAL_ICACHE_MODULE_ENABLED
HAL_ICACHE_Disable();
as you do in EE_Format() function.
In your EE_Init(), when accessing FLASH_SIZE macro and you have ICACHE enabled in your project, hardfault is triggered.
Valid for at least for my H563ZI.
Possible solutions:
void MPU_Config(void) {
HAL_MPU_Disable();
}
Do not understand why you didn't call here
#ifdef HAL_ICACHE_MODULE_ENABLED
HAL_ICACHE_Disable();
as you do in EE_Format() function.