打印

在DM642中怎样才能精确延时呢?请各位前辈给指点一下!

[复制链接]
2419|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
ccjchen|  楼主 | 2009-7-23 16:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
zhongxon| | 2009-7-23 17:25 | 只看该作者

re

在642中也可以用nop指令。就是在C语言中加入汇编指令。
asm("    nop 8");就等于是加入了8个nop指令,比c51方便。

不过延时100us用这种方法太耗费DSP的运算能力了。

使用特权

评论回复
板凳
ccjgalaxy| | 2009-7-23 21:14 | 只看该作者

hehe

那如果我的DM642系统时钟是600MHz的话,一个 nop 相当于延时多长时间啊

使用特权

评论回复
地板
shixiudong| | 2009-7-26 21:51 | 只看该作者

说几句

由于CCS的编译优化,使得采用NOP延时的老办法无效。如下是一个成熟的方法。

方法:用DM642的定时器2作精确延时。
效果:应用在成熟产品中,很可靠并支持重入机制。
程序:如下

/////////////////////////////////////////////////////////////////////
// function:    Wait_uSeccond
// 
// Descript:    Spin in a delay loop for delay microseconds
// Note:        (1) Timer-2 does not trig a interrupt.
//            (2) The MAX time is 57.2662306 seconds at CPU clock 600 MHz.
//            (3) 1uS = 75 cycle.
//////////////////////////////////////////////////////////////////////
void Wait_uSeccond( Uint32 ui32Delay)
{
    Uint32        cnt;
    TIMER_Config    cfgTimer2;

    // save Timer2 old settings
    TIMER_getConfig( hTimer2, &cfgTimer2);

    cnt = 75*ui32Delay;

    // clear the timer count register
    TIMER_setCount( hTimer2, 0x00000000);

    // resume the timer2
    TIMER_resume( hTimer2);

    // wait until time=delay
    while( TIMER_getCount( hTimer2) < cnt);

    // Reconfigure Timer2 with old settings
    TIMER_config( hTimer2, &cfgTimer2);
}

使用特权

评论回复
5
ccjchen|  楼主 | 2009-7-27 13:27 | 只看该作者

我刚学DSP不久

弱弱的问一下,用DM642的定时器2不是通常用作SDRAM的定时中断吗?还能用作程序其他部分的延时吗?

使用特权

评论回复
6
zhongxon| | 2009-7-28 09:56 | 只看该作者

史版主,好久不见了,生意好吗。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

175

主题

446

帖子

1

粉丝