mjl090 发表于 2017-7-23 11:26:24

把数组放到ccm中,速度反而变慢了

测试结果:

keil打开代码优化的情况下,放在ram和ccm中速度是一样的,耗时=1000
关闭优化,ram耗时=1000,ccm耗时=1125

根据手册上的数据,ccm比ram快20%,可是测试结果ccm反而慢了10%

求高手解答

测试方法就是让一个4k的数组++,分别放到ram和ccm中,1000次以后用flash记录下时间
(定时器ARR和PSC都是0xFFFF)
/*
vu8 cc ={0};
vu8 cc2={0};
vu32 cCnt =0;
vu32 tCnt={0};
vu32 i=0;
*/


vu8 cc __attribute__((at(0x10000000))) ={0};
vu32 cCnt __attribute__((at(0x10001000))) =0;
vu32 tCnt __attribute__((at(0x10001004))) ={0};
vu8 cc2 __attribute__((at(0x10001008))) ={0};
vu32 __attribute__((at(0x10002008))) i=0;




while(1)
{
++cCnt;
for(i=0; i<4096;++i)
{
      ++cc【i】;
      cc2=TIM3->CNT;
}
if(cCnt==1000)
{
      tCnt=TIM3->CNT;
      
      STMFLASH_Write(0X0800C008,(u32*)tCnt,1);
      
      GPIOD->ODR^=0x1000;
      while(1);
}

}


MrJiu 发表于 2017-7-24 08:39:42

ccm啥东西?我去,都没听过!!:'(:'(

moyanming2013 发表于 2017-7-24 12:08:17

1.是否配置了正确的分散加载文件?
2.自己的程序部分确定没写错吧?
3.参考AN4296
以及:
https://www.stmcu.org.cn/module/forum/forum.php?mod=viewthread&tid=602255&extra=page%3D&page=1


页: [1]
查看完整版本: 把数组放到ccm中,速度反而变慢了