sunsundsp 发表于 2013-11-5 16:39

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


    没有一起用过的经验 网上找了一些例子程序

发现用了之后 还是只有定时器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

解决了

zhangmangui 发表于 2013-11-5 18:50

sunsundsp 发表于 2013-11-5 18:05 static/image/common/back.gif
解决了

那就算分享吧呵呵

lvpengxi 发表于 2015-5-27 16:46

sunsundsp 发表于 2013-11-5 18:05
解决了

如何解决的,求分享

海中水 发表于 2015-5-27 19:09

是不是还是因为中断配置的问题呢?

changzhouds 发表于 2018-5-28 15:37

你好,如何解决的呢请问一下
页: [1]
查看完整版本: dsp2812 同时使用定时器0和2,遇到一些问题