本帖最后由 hpdell 于 2017-10-24 22:22 编辑
为何使用nand flash 后,sdram的速度会变慢 ?
具体设置如下:
mpu设置:
static void MPU_Set_Protection(uint32_t baseaddr,
uint32_t size,
uint32_t rnum,
uint32_t ap,
u8 sen,
u8 cen,
u8 ben)
{
MPU_Region_InitTypeDef MPU_Initure;
HAL_MPU_Disable(); //配置MPU之前先关闭MPU,配置完成以后在使能MPU
MPU_Initure.Enable = MPU_REGION_ENABLE; //使能该保护区域
MPU_Initure.Number = rnum; //设置保护区域
MPU_Initure.BaseAddress = baseaddr; //设置基址
MPU_Initure.Size = size; //设置保护区域大小
MPU_Initure.SubRegionDisable = 0x00; //禁止子区域
MPU_Initure.TypeExtField = MPU_TEX_LEVEL0; //设置类型扩展域为level0
MPU_Initure.AccessPermission = (uint8_t)ap; //设置访问权限,
MPU_Initure.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE; //允许指令访问(允许读取指令)
MPU_Initure.IsShareable = sen; //是否允许共用
MPU_Initure.IsCacheable = cen; //是否允许cache
MPU_Initure.IsBufferable = ben; //是否允许缓冲
HAL_MPU_ConfigRegion(&MPU_Initure); //配置MPU
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); //开启MPU
}
// 显示设置
MPU_Set_Protection(0x60000000,
MPU_REGION_SIZE_64MB,
MPU_REGION_NUMBER0,
MPU_REGION_FULL_ACCESS,
MPU_ACCESS_NOT_SHAREABLE,
MPU_ACCESS_CACHEABLE,
MPU_ACCESS_BUFFERABLE);
// sram设置
MPU_Set_Protection(0x20000000,
MPU_REGION_SIZE_512KB,
MPU_REGION_NUMBER1,
MPU_REGION_FULL_ACCESS,
MPU_ACCESS_NOT_SHAREABLE,
MPU_ACCESS_CACHEABLE,
MPU_ACCESS_BUFFERABLE);
//外部sdram 设置
MPU_Set_Protection(0xC0000000,
MPU_REGION_SIZE_64MB,
MPU_REGION_NUMBER2,
MPU_REGION_FULL_ACCESS,
MPU_ACCESS_NOT_SHAREABLE,
MPU_ACCESS_CACHEABLE,
MPU_ACCESS_BUFFERABLE);
void static NAND_MPU_Config(void)
{
MPU_Region_InitTypeDef MPU_Initure;
HAL_MPU_Disable(); //配置MPU之前先关闭MPU,配置完成以后在使能MPU
//配置RAM为region1,大小为256MB,此区域可读写
MPU_Initure.Enable = MPU_REGION_ENABLE;
MPU_Initure.Number = MPU_REGION_NUMBER3;
MPU_Initure.BaseAddress = ((uint32_t)NAND_ADDRESS_START); // 0x8000 0000
MPU_Initure.Size = MPU_REGION_SIZE_2GB;
MPU_Initure.SubRegionDisable = 0x00;
MPU_Initure.TypeExtField = MPU_TEX_LEVEL0;
MPU_Initure.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_Initure.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
// 最后三项设置 影响 sdram 的运行速度等 ???????????????????????
MPU_Initure.IsShareable = MPU_ACCESS_NOT_SHAREABLE; // 禁止共用
MPU_Initure.IsCacheable = MPU_ACCESS_NOT_CACHEABLE; //禁止cache
MPU_Initure.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE; //禁止缓冲
HAL_MPU_ConfigRegion(&MPU_Initure);
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT); //开启MPU
}
对于 nand flash 的设置,如果最后的三个不设置为禁止的话,读写 nand flash 失败,如果按照上面的最后三项设置的话,等读写nand flash 测试完成后,再使用解码jpg程序时,速度会慢 80%左右,这是为何啊 ??
正常如果不使用nand flash,解码 1024*600的图片大概需要 130ms左右,使用nand flash 后,解码同样的大小的通一个文件,大概需要 265ms左右,而且后续再使用sdram也会进入硬件错误了,这又是为何啊 ????????
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>