打印
[时钟]

dsp2812 同时使用定时器0和2,遇到一些问题

[复制链接]
3506|7
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
sunsundsp|  楼主 | 2013-11-5 16:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  
    没有一起用过的经验 网上找了一些例子程序

发现用了之后 还是只有定时器0在工作 ,定时器2的中断根本没进去过 想知道原因
附上自己的程序:

#include "DSP281x_Device.h"
#include "example_nonBIOS.h"
#include "main.h"
#define StartCpuTimer0()  CpuTimer0Regs.TCR.bit.TSS = 0
#define StartCpuTimer2()  CpuTimer2Regs.TCR.bit.TSS = 0

void User_Init(void);
interrupt void cpu_timer0_isr(void);
interrupt void cpu_timer2_isr(void);

void main(void)
{
    /*** CPU Initialization ***/
    InitSysCtrl();  //Initialize the CPU (FILE: SysCtrl.c)
    DINT;
    IER = 0x0000; // Disable CPU interrupts
    IFR = 0x0000; // Clear all CPU interrupt flags
    InitXintf();  //Initialize the external memory interface (FILE: Xintf.c)
    //InitGpio();  // Initialize the shared GPIO pins (FILE: Gpio.c)
    InitPieCtrl();  // Initialize and enable the PIE (FILE: PieCtrl.c)
    InitEv();   // Initialize the EV(FILE: Ev.c)--And initialize the Timer1
    InitCpuTimers();
// Initialize the time (FILE: DSP281x_CpuTimers.c)
    //FFT();
     EALLOW;    // This is needed to write to EALLOW protected registers
    PieVectTable.TINT0 = &cpu_timer0_isr;//timer0中断服务子程序重定位
    PieVectTable.TINT2 = &cpu_timer2_isr;//timer0中断服务子程序重定位

    EDIS;      // This is needed to disable write to EALLOW protected registers
    IER |=(M_INT1|M_INT14);  // EV Interrupt
    IFR &= 0x0000;  //Clear all interrupt flag
     PieCtrlRegs.PIEIER1.bit.INTx7 = 1;// Enable TINT0 in the PIE: Group 1 interrupt 7
  
    //SetDBGIER(IER);  // Configure the DBGIER for realtime debug        
    EINT;    // Enable global interrupts and realtime debug
ERTM;
    //asm(" CLRC INTM, DBGM");
    StartCpuTimer0();
    StartCpuTimer2();

while(1)
{}
}
interrupt void cpu_timer0_isr(void)
{   
Count_AD++;

PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
    }


interrupt void cpu_timer2_isr(void)
{
  
  COUNT++;
  PieCtrlRegs.PIEACK.all = PIEACK_GROUP2;
}

相关帖子

沙发
sunsundsp|  楼主 | 2013-11-5 16:50 | 只看该作者
我怀疑是不是因为 没有对定时器2的中断使能 因为定时器0有这么一句话PieCtrlRegs.PIEIER1.bit.INTx7 = 1
然后定时器2中断函数 里也没有中断应答 PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
但是如果加的话 不知道定时器2的中断int14 算是哪组的呢?

使用特权

评论回复
板凳
sunsundsp|  楼主 | 2013-11-5 16:58 | 只看该作者
刚看到一句话 timer0是属于CPU 外部中断,由PIE 管理,而TIMER2 属于CPU 内部中断,由 CPU 直接管理。两者的具体编程方法有差别   

具体差别是什么呢?

使用特权

评论回复
地板
sunsundsp|  楼主 | 2013-11-5 18:05 | 只看该作者
解决了

使用特权

评论回复
5
zhangmangui| | 2013-11-5 18:50 | 只看该作者
sunsundsp 发表于 2013-11-5 18:05
解决了

那就算分享吧  呵呵

使用特权

评论回复
6
lvpengxi| | 2015-5-27 16:46 | 只看该作者

如何解决的,求分享

使用特权

评论回复
7
海中水| | 2015-5-27 19:09 | 只看该作者
是不是还是因为中断配置的问题呢?

使用特权

评论回复
8
changzhouds| | 2018-5-28 15:37 | 只看该作者
你好,如何解决的呢请问一下

使用特权

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

本版积分规则

29

主题

122

帖子

2

粉丝