This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

280x定时器问题

您好!我想采用定时器10kHz起动AD中断,280x与2812在这方面操作不太一样。请问1:用cputimer0的话,目前的问题是ConfigCpuTimer(&CpuTimer0,100,100); 时间计算的不对,不知道为什么  问2:采用其它定时器的话,怎样操作,280x的比较复杂 谢谢!

  • 楼主看一下ConfigCpuTimer程序吧。

    其他定时器一样操作。

    void ConfigCpuTimer(struct CPUTIMER_VARS *Timer, float Freq, float Period)

    {

       Uint32 temp;

       Timer->CPUFreqInMHz = Freq;             //写入当前CPU的频率

       Timer->PeriodInUSec = Period;           //写入定时器的周期时间(uS为单位)

       temp = (long) (Freq * Period);          //计算出需要设定的timer的周期数值

       Timer->RegsAddr->PRD.all = temp;        //设置CpuTimerx的周期值

       Timer->RegsAddr->TPR.all  = 0;          //不进行分频,即TIM的递减速度等于SYSCLKOUT

       Timer->RegsAddr->TPRH.all  = 0;

       Timer->RegsAddr->TCR.bit.TSS = 1;       //停止计数

     Timer->RegsAddr->TCR.bit.TRB = 1;       //重新装载计数器  

       Timer->RegsAddr->TCR.bit.SOFT = 0;

       Timer->RegsAddr->TCR.bit.FREE = 0;      // 禁止Free Run

       Timer->RegsAddr->TCR.bit.TIE = 1;       // 定时器中断允许

       Timer->InterruptCount = 0;              //复位中断计数

    }