[讨论] 求助为什么2812外部RAM读写速度提不高?

小an   2015-3-6 22:38 楼主
又有问题得麻烦热心的坛友们了,我写了个2812的外部ram测试代码。
xintf.c内配置如下:
void InitXintf(void)
{
    // #if  F2812
    // Example of chaning the timing of XINTF Zones.  
    // Note acutal values should be based on the hardware
    // attached to the zone - timings presented here are
    // for example purposes.
     
    // All Zones---------------------------------
    // Timing for all zones based on XTIMCLK = SYSCLKOUT
    XintfRegs.XINTCNF2.bit.XTIMCLK = 0;
    // No write buffering
    XintfRegs.XINTCNF2.bit.WRBUFF = 0;
    // XCLKOUT is enabled
    XintfRegs.XINTCNF2.bit.CLKOFF = 0;
    // XCLKOUT = XTIMCLK/2
    XintfRegs.XINTCNF2.bit.CLKMODE = 1;            //XCLK=75MHz
  
    // Zone 6:
    // Change write access lead active trail timing
   // When using ready, ACTIVE must be 1 or greater
   // Lead must always be 1 or greater
   // Use timings based on SYSCLKOUT = XTIMCLK

    XintfRegs.XTIMING6.bit.USEREADY=0;
    XintfRegs.XTIMING6.bit.XSIZE=3;
    XintfRegs.XTIMING6.bit.XWRTRAIL = 1;
    XintfRegs.XTIMING6.bit.XWRACTIVE = 2;
    XintfRegs.XTIMING6.bit.XWRLEAD = 1;
    XintfRegs.XTIMING6.bit.XRDLEAD = 1;
    XintfRegs.XTIMING6.bit.XRDACTIVE = 2;
    XintfRegs.XTIMING6.bit.XRDTRAIL = 1;
    //Not double lead/active/trail for Zone 6
    XintfRegs.XTIMING6.bit.X2TIMING = 0;          //时钟不翻倍
    // Zone 6 is slow, so add additional BCYC cycles when ever switching
    // from Zone 6 to another Zone.  This will help avoid
    // bus contention.
    XintfRegs.XBANK.bit.BCYC = 2;
    XintfRegs.XBANK.bit.BANK = 6;

// #endif
}
main函数中每次往外部RAM写16K数据,写完后将一个GPIO翻转。现在得到的结果是按上述void InitXintf(void)配置GPIO口的方波只有163Hz左右,换算过来外部RAM写入速度只有2.8MHz左右。但是按上述配置理论上应该是(150MHz/2)/(1+2+1)=18.75MHz才对吧。而且我把XWRTRAIL、XWRACTIVE、XWRLEAD这三个时间分别设为1,1,1时,GPIO输出方波频率也只增加到176Hz,而如果改为3、7、3则方波为127Hz。这和手册上说的不符合啊,有哪位坛友知道问题出在哪里吗?谢谢赐教


回复评论 (6)

测量外部ram各引脚上的信号,发现CE和WE的确只有2MHz多点,那么应该是2812产生的信号有问题
点赞  2015-3-7 10:34
没有测试过这个东西,也没有关注过。感觉测试方法没有问题 void InitXintf(void) { #if DSP28_F2812 // This shows how to write to the XINTF registers. The // values used here are the default state after reset. // Different hardware will require a different configuration. // For an example of an XINTF configuration used with the // F2812 eZdsp, refer to the examples/run_from_xintf project. // Any changes to XINTF timing should only be made by code // running outside of the XINTF. // All Zones--------------------------------- // Timing for all zones based on XTIMCLK = 1/2 SYSCLKOUT XintfRegs.XINTCNF2.bit.XTIMCLK = 1; // No write buffering XintfRegs.XINTCNF2.bit.WRBUFF = 0; // XCLKOUT is enabled XintfRegs.XINTCNF2.bit.CLKOFF = 0; // XCLKOUT = XTIMCLK/2 XintfRegs.XINTCNF2.bit.CLKMODE = 1; // Zone 0------------------------------------ // When using ready, ACTIVE must be 1 or greater // Lead must always be 1 or greater // Zone write timing XintfRegs.XTIMING0.bit.XWRLEAD = 3; XintfRegs.XTIMING0.bit.XWRACTIVE = 7; XintfRegs.XTIMING0.bit.XWRTRAIL = 3; // Zone read timing XintfRegs.XTIMING0.bit.XRDLEAD = 3; XintfRegs.XTIMING0.bit.XRDACTIVE = 7; XintfRegs.XTIMING0.bit.XRDTRAIL = 3; // double all Zone read/write lead/active/trail timing XintfRegs.XTIMING0.bit.X2TIMING = 1; // Zone will sample XREADY signal XintfRegs.XTIMING0.bit.USEREADY = 1; XintfRegs.XTIMING0.bit.READYMODE = 1; // sample asynchronous // Size must be 1,1 - other values are reserved XintfRegs.XTIMING0.bit.XSIZE = 3; // Zone 1------------------------------------ // When using ready, ACTIVE must be 1 or greater // Lead must always be 1 or greater // Zone write timing XintfRegs.XTIMING1.bit.XWRLEAD = 3; XintfRegs.XTIMING1.bit.XWRACTIVE = 7; XintfRegs.XTIMING1.bit.XWRTRAIL = 3; // Zone read timing XintfRegs.XTIMING1.bit.XRDLEAD = 3; XintfRegs.XTIMING1.bit.XRDACTIVE = 7; XintfRegs.XTIMING1.bit.XRDTRAIL = 3; // double all Zone read/write lead/active/trail timing XintfRegs.XTIMING1.bit.X2TIMING = 1; // Zone will sample XREADY signal XintfRegs.XTIMING1.bit.USEREADY = 1; XintfRegs.XTIMING1.bit.READYMODE = 1; // sample asynchronous // Size must be 1,1 - other values are reserved XintfRegs.XTIMING1.bit.XSIZE = 3; // Zone 2------------------------------------ // When using ready, ACTIVE must be 1 or greater // Lead must always be 1 or greater // Zone write timing XintfRegs.XTIMING2.bit.XWRLEAD = 3; XintfRegs.XTIMING2.bit.XWRACTIVE = 7; XintfRegs.XTIMING2.bit.XWRTRAIL = 3; // Zone read timing XintfRegs.XTIMING2.bit.XRDLEAD = 3; XintfRegs.XTIMING2.bit.XRDACTIVE = 7; XintfRegs.XTIMING2.bit.XRDTRAIL = 3; // double all Zone read/write lead/active/trail timing XintfRegs.XTIMING2.bit.X2TIMING = 1; // Zone will sample XREADY signal XintfRegs.XTIMING2.bit.USEREADY = 1; XintfRegs.XTIMING2.bit.READYMODE = 1; // sample asynchronous // Size must be 1,1 - other values are reserved XintfRegs.XTIMING2.bit.XSIZE = 3; // Zone 6------------------------------------ // When using ready, ACTIVE must be 1 or greater // Lead must always be 1 or greater // Zone write timing XintfRegs.XTIMING6.bit.XWRLEAD = 3; XintfRegs.XTIMING6.bit.XWRACTIVE = 7; XintfRegs.XTIMING6.bit.XWRTRAIL = 3; // Zone read timing XintfRegs.XTIMING6.bit.XRDLEAD = 3; XintfRegs.XTIMING6.bit.XRDACTIVE = 7; XintfRegs.XTIMING6.bit.XRDTRAIL = 3; // double all Zone read/write lead/active/trail timing XintfRegs.XTIMING6.bit.X2TIMING = 1; // Zone will sample XREADY signal XintfRegs.XTIMING6.bit.USEREADY = 1; XintfRegs.XTIMING6.bit.READYMODE = 1; // sample asynchronous // Size must be 1,1 - other values are reserved XintfRegs.XTIMING6.bit.XSIZE = 3; // Zone 7------------------------------------ // When using ready, ACTIVE must be 1 or greater // Lead must always be 1 or greater // Zone write timing XintfRegs.XTIMING7.bit.XWRLEAD = 3; XintfRegs.XTIMING7.bit.XWRACTIVE = 7; XintfRegs.XTIMING7.bit.XWRTRAIL = 3; // Zone read timing XintfRegs.XTIMING7.bit.XRDLEAD = 3; XintfRegs.XTIMING7.bit.XRDACTIVE = 7; XintfRegs.XTIMING7.bit.XRDTRAIL = 3; // double all Zone read/write lead/active/trail timing XintfRegs.XTIMING7.bit.X2TIMING = 1; // Zone will sample XREADY signal XintfRegs.XTIMING7.bit.USEREADY = 1; XintfRegs.XTIMING7.bit.READYMODE = 1; // sample asynchronous // Size must be 1,1 - other values are reserved XintfRegs.XTIMING7.bit.XSIZE = 3; // Bank switching // Assume Zone 7 is slow, so add additional BCYC cycles // when ever switching from Zone 7 to another Zone. // This will help avoid bus contention. XintfRegs.XBANK.bit.BANK = 7; XintfRegs.XBANK.bit.BCYC = 7; //Force a pipeline flush to ensure that the write to //the last register configured occurs before returning. asm(" RPT #7 || NOP"); #endif } 这个是我用的初始化函数,帮忙测一下呗 本帖最后由 jishuaihu 于 2015-3-9 09:24 编辑
点赞  2015-3-9 09:23
引用: jishuaihu 发表于 2015-3-9 09:23
没有测试过这个东西,也没有关注过。感觉测试方法没有问题
void InitXintf(void)
{

#if DSP28_F2812

    // This shows how to write to the XINTF registers.  The
    // values used here are the default state after reset.
    // Different hardware will require a different configuration.

    // For an example of an XINTF configuration used with the
    // F2812 eZdsp, refer to the examples/run_from_xintf project.

    // Any changes to XINTF timing should only be made by code
    // running outside of the XINTF.

    // All Zones---------------------------------
    // Timing for all zones based on XTIMCLK = 1/2 SYSCLKOUT
    XintfRegs.XINTCNF2.bit.XTIMCLK = 1;
    // No write buffering
    XintfRegs.XINTCNF2.bit.WRBUFF = 0;
    // XCLKOUT is enabled
    XintfRegs.XINTCNF2.bit.CLKOFF = 0;
    // XCLKOUT = XTIMCLK/2
    XintfRegs.XINTCNF2.bit.CLKMODE = 1;


    // Zone 0------------------------------------
    // When using ready, ACTIVE must be 1 or greater
    // Lead must always be 1 or greater
    // Zone write timing
    XintfRegs.XTIMING0.bit.XWRLEAD = 3;
    XintfRegs.XTIMING0.bit.XWRACTIVE = 7;
    XintfRegs.XTIMING0.bit.XWRTRAIL = 3;
    // Zone read timing
    XintfRegs.XTIMING0.bit.XRDLEAD = 3;
    XintfRegs.XTIMING0.bit.XRDACTIVE = 7;
    XintfRegs.XTIMING0.bit.XRDTRAIL = 3;

    // double all Zone read/write lead/active/trail timing
    XintfRegs.XTIMING0.bit.X2TIMING = 1;

    // Zone will sample XREADY signal
    XintfRegs.XTIMING0.bit.USEREADY = 1;
    XintfRegs.XTIMING0.bit.READYMODE = 1;  // sample asynchronous

    // Size must be 1,1 - other values are reserved
    XintfRegs.XTIMING0.bit.XSIZE = 3;

    // Zone 1------------------------------------
    // When using ready, ACTIVE must be 1 or greater
    // Lead must always be 1 or greater
    // Zone write timing
    XintfRegs.XTIMING1.bit.XWRLEAD = 3;
    XintfRegs.XTIMING1.bit.XWRACTIVE = 7;
    XintfRegs.XTIMING1.bit.XWRTRAIL = 3;
    // Zone read timing
    XintfRegs.XTIMING1.bit.XRDLEAD = 3;
    XintfRegs.XTIMING1.bit.XRDACTIVE = 7;
    XintfRegs.XTIMING1.bit.XRDTRAIL = 3;

    // double all Zone read/write lead/active/trail timing
    XintfRegs.XTIMING1.bit.X2TIMING = 1;

    // Zone will sample XREADY signal
    XintfRegs.XTIMING1.bit.USEREADY = 1;
    XintfRegs.XTIMING1.bit.READYMODE = 1;  // sample asynchronous

    // Size must be 1,1 - other values are reserved
    XintfRegs.XTIMING1.bit.XSIZE = 3;

    // Zone 2------------------------------------
    // When using ready, ACTIVE must be 1 or greater
    // Lead must always be 1 or greater
    // Zone write timing
    XintfRegs.XTIMING2.bit.XWRLEAD = 3;
    XintfRegs.XTIMING2.bit.XWRACTIVE = 7;
    XintfRegs.XTIMING2.bit.XWRTRAIL = 3;
    // Zone read timing
    XintfRegs.XTIMING2.bit.XRDLEAD = 3;
    XintfRegs.XTIMING2.bit.XRDACTIVE = 7;
    XintfRegs.XTIMING2.bit.XRDTRAIL = 3;

    // double all Zone read/write lead/active/trail timing
    XintfRegs.XTIMING2.bit.X2TIMING = 1;

    // Zone will sample XREADY signal
    XintfRegs.XTIMING2.bit.USEREADY = 1;
    XintfRegs.XTIMING2.bit.READYMODE = 1;  // sample asynchronous

    // Size must be 1,1 - other values are reserved
    XintfRegs.XTIMING2.bit.XSIZE = 3;


    // Zone 6------------------------------------
    // When using ready, ACTIVE must be 1 or greater
    // Lead must always be 1 or greater
    // Zone write timing
    XintfRegs.XTIMING6.bit.XWRLEAD = 3;
    XintfRegs.XTIMING6.bit.XWRACTIVE = 7;
    XintfRegs.XTIMING6.bit.XWRTRAIL = 3;
    // Zone read timing
    XintfRegs.XTIMING6.bit.XRDLEAD = 3;
    XintfRegs.XTIMING6.bit.XRDACTIVE = 7;
    XintfRegs.XTIMING6.bit.XRDTRAIL = 3;

    // double all Zone read/write lead/active/trail timing
    XintfRegs.XTIMING6.bit.X2TIMING = 1;

    // Zone will sample XREADY signal
    XintfRegs.XTIMING6.bit.USEREADY = 1;
    XintfRegs.XTIMING6.bit.READYMODE = 1;  // sample asynchronous

    // Size must be 1,1 - other values are reserved
    XintfRegs.XTIMING6.bit.XSIZE = 3;


    // Zone 7------------------------------------
    // When using ready, ACTIVE must be 1 or greater
    // Lead must always be 1 or greater
    // Zone write timing
    XintfRegs.XTIMING7.bit.XWRLEAD = 3;
    XintfRegs.XTIMING7.bit.XWRACTIVE = 7;
    XintfRegs.XTIMING7.bit.XWRTRAIL = 3;
    // Zone read timing
    XintfRegs.XTIMING7.bit.XRDLEAD = 3;
    XintfRegs.XTIMING7.bit.XRDACTIVE = 7;
    XintfRegs.XTIMING7.bit.XRDTRAIL = 3;

    // double all Zone read/write lead/active/trail timing
    XintfRegs.XTIMING7.bit.X2TIMING = 1;

    // Zone will sample XREADY signal
    XintfRegs.XTIMING7.bit.USEREADY = 1;
    XintfRegs.XTIMING7.bit.READYMODE = 1;  // sample asynchronous

    // Size must be 1,1 - other values are reserved
    XintfRegs.XTIMING7.bit.XSIZE = 3;

    // Bank switching
    // Assume Zone 7 is slow, so add additional BCYC cycles
    // when ever switching from Zone 7 to another Zone.
    // This will help avoid bus contention.
    XintfRegs.XBANK.bit.BANK = 7;
    XintfRegs.XBANK.bit.BCYC = 7;

   //Force a pipeline flush to ensure that the write to
   //the last register configured occurs before returning.

   asm(" RPT #7 || NOP");

    #endif
}
这个是我用的初始化函数,帮忙测一下呗
这个就是TI官方例程的配置,肯定没问题。其实如果是这个配置的话,到时候调不调用这个初始化函数都一样,因为2812上电时默认就是这个配置。



点赞  2015-3-9 19:19
我也是从别人哪儿拿的,没有仔细看跟官方例程有什么区别。
你用这个例程测试可以确认测试方法有没有问题
点赞  2015-3-9 19:26
我的问题,最后判断应该是每两次写外部RAM之间要执行的语句比较多。因为操作外部RAM需要计算存放地址,还要判断是不是存足16K数据了,从汇编看需要执行7条语句,加上RAM存取本来就至少要有3个周期的等待时间,所以最后导致速度慢。至于50MHz的最大速度,我的理解是这样的。TI的例程和手册都在讲把程序放到外部RAM运行,这时候可能不需要CPU耗费时钟周期来计算存放地址,因为PC都是自动指向下一条要执行的代码的。
点赞  2015-3-9 19:27
代码运行还有其他的动作占用了MCU时间,比哪循环判断,分支指令等,计算时需要把这些指令的时间考虑进去。
另外,外设初始化之后,可以通过CCS检查外设控制寄存器,配置信息是否正确写入配置寄存器。

电子工程师技术交流QQ群:12425841,专注于自动控制、数字电源等
点赞  2015-3-10 09:50
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复