新手上路
- 积分
- 36
- 金钱
- 36
- 注册时间
- 2019-10-16
- 在线时间
- 16 小时
|
15金钱
最近移植LWIP的时候用到了MPU,对一些配置有些不解,请大佬们解答!
经过查资料得知如下这个配置的意思是:默认区域(default region)仅允许特权访问,并且在硬故障,NMI和FAULTMASK处理程序期间禁用MPU
- HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
复制代码
那么我访问默认区域(访问的0x24000000@512K这一块RAM)的时候为什么没进MemManage_Handler(void)中断呢?
具体MPU配置代码如下:
- void MPU_Config(void)
- {
- MPU_Region_InitTypeDef MPU_InitStruct = {0};
- /* Disables the MPU */
- HAL_MPU_Disable();
- /** Initializes and configures the Region and the memory to be protected
- */
- MPU_InitStruct.Enable = MPU_REGION_ENABLE;
- MPU_InitStruct.Number = MPU_REGION_NUMBER0;
- MPU_InitStruct.BaseAddress = 0x30040000;
- MPU_InitStruct.Size = MPU_REGION_SIZE_256B;
- MPU_InitStruct.SubRegionDisable = 0x0;
- MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
- MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
- MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
- MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
- MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
- MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
- HAL_MPU_ConfigRegion(&MPU_InitStruct);
- /** Initializes and configures the Region and the memory to be protected
- */
- MPU_InitStruct.Number = MPU_REGION_NUMBER1;
- MPU_InitStruct.BaseAddress = 0x30044000;
- MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
- MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
- MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
- HAL_MPU_ConfigRegion(&MPU_InitStruct);
- /* Enables the MPU */
- HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
- }
复制代码
|
|