如果一个程序中,有两个中断,假若为CAP1中断和CAP2中断,我查到DSP默认的优先级是CAP2级别高于CAP1,
是不是当CAP2满足中断条件后,CAP2进入中断,即使此刻CAP1也满足中断条件,也不会进入CAP1中断??
还有就是如果自始至终,CAP1和CAP2都满足中断条件的话,CAP1就会一直进不去中断??
我在实际测量中发现,分别用两个信号发生器 都产生两个50hz的 高低电平信号,幅值满足DSP能够进入中断的要求。
测试中发现,当仅有CAP1中断时,可以正常捕获数值,CAP1的两个寄存器差值为50HZ对应数字量,当仅有CAP2中断时,也可以正常捕获数值,CAP2的两个寄存器差值与CAP1基本差别不大。由此可以确定两个CAP中断没有问题。
但是,当CAP1和CAP2同时满足中断条件时,根据程序单步运行发现,两个中断也都能进入,但是捕获数值不正确。此时CAP1和CAP2的两个寄存器虽然数值时刻在变化,但是差值始终为0,一直弄不清原因,求救中...............
主要程序如下:
#include "DSP280x_Device.h" // DSP280x Headerfile Include File
#include "DSP280x_Examples.h" // DSP280x Examples Include File
interrupt void ecap1_isr(void);
interrupt void ecap2_isr(void);
void InitECapture(void);
void Fail(void);
// Global variables used in this example
Uint32 ECap1IntCount;
Uint32 ECap2IntCount;
Uint32 TSt1;
Uint32 TSt2;
Uint32 TSt3;
Uint32 TSt4;
Uint32 Period1;
Uint32 Period2;
void main(void)
{
InitSysCtrl();
InitECap1Gpio();
InitECap2Gpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.ECAP1_INT = &ecap1_isr;
PieVectTable.ECAP2_INT = &ecap2_isr;
EDIS;
InitECapture();
ECap1IntCount = 0;
ECap2IntCount = 0;
IER |= M_INT4;
PieCtrlRegs.PIEIER4.bit.INTx1 = 1;
PieCtrlRegs.PIEIER4.bit.INTx2 = 1;
EINT;
ERTM;
for(;;)
{
asm(" NOP");
}
}
void InitECapture()
{
ECap1Regs.ECEINT.all = 0x0000;
ECap1Regs.ECCLR.all = 0xFFFF;
ECap1Regs.ECCTL1.bit.CAPLDEN = 0;
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;
ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1;
ECap1Regs.ECCTL2.bit.STOP_WRAP = 3;
ECap1Regs.ECCTL1.bit.CAP1POL = 1;
ECap1Regs.ECCTL1.bit.CAP2POL = 1;
ECap1Regs.ECCTL1.bit.CAP3POL = 1;
ECap1Regs.ECCTL1.bit.CAP4POL = 1;
ECap1Regs.ECCTL1.bit.CTRRST1 = 0;
ECap1Regs.ECCTL1.bit.CTRRST2 = 0;
ECap1Regs.ECCTL1.bit.CTRRST3 = 0;
ECap1Regs.ECCTL1.bit.CTRRST4 = 0;
ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;
ECap1Regs.ECCTL1.bit.CAPLDEN = 1;
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1;
ECap1Regs.ECCTL2.bit.REARM = 1;
ECap1Regs.ECCTL1.bit.CAPLDEN = 1;
ECap1Regs.ECEINT.bit.CEVT4 = 1;
ECap2Regs.ECEINT.all = 0x0000;
ECap2Regs.ECCLR.all = 0xFFFF;
ECap2Regs.ECCTL1.bit.CAPLDEN = 0;
ECap2Regs.ECCTL2.bit.TSCTRSTOP = 0;
ECap2Regs.ECCTL2.bit.CONT_ONESHT = 1;
ECap2Regs.ECCTL2.bit.STOP_WRAP = 3;
ECap2Regs.ECCTL1.bit.CAP1POL = 1;
ECap2Regs.ECCTL1.bit.CAP2POL = 1;
ECap2Regs.ECCTL1.bit.CAP3POL = 1;
ECap2Regs.ECCTL1.bit.CAP4POL = 1;
ECap2Regs.ECCTL1.bit.CTRRST1 = 0;
ECap2Regs.ECCTL1.bit.CTRRST2 = 0;
ECap2Regs.ECCTL1.bit.CTRRST3 = 0;
ECap2Regs.ECCTL1.bit.CTRRST4 = 0;
ECap2Regs.ECCTL2.bit.SYNCI_EN = 0;
ECap2Regs.ECCTL2.bit.SYNCO_SEL = 2;
ECap2Regs.ECCTL1.bit.CAPLDEN = 1;
ECap2Regs.ECCTL2.bit.TSCTRSTOP = 1;
ECap2Regs.ECCTL2.bit.REARM = 1;
ECap2Regs.ECCTL1.bit.CAPLDEN = 1;
ECap2Regs.ECEINT.bit.CEVT4 = 1;
}
interrupt void ecap1_isr(void)
{
TSt1 = ECap1Regs.CAP1;
TSt2 = ECap1Regs.CAP2;
Period1 = TSt2-TSt1;
ECap1IntCount++;
ECap1Regs.ECCLR.bit.CEVT4= 1;
ECap1Regs.ECCLR.bit.INT = 1;
ECap1Regs.ECCTL2.bit.REARM = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
interrupt void ecap2_isr(void)
{
TSt3 = ECap2Regs.CAP1;
TSt4 = ECap2Regs.CAP2;
Period2 = TSt4-TSt3;
ECap2IntCount++;
Period4=abs(TSt3-TSt1);
ECap2Regs.ECCLR.bit.CEVT4 = 1;
ECap2Regs.ECCLR.bit.INT = 1;
ECap2Regs.ECCTL2.bit.REARM = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
void Fail()
{
asm(" ESTOP0");
}
//===========================================================================
// No more.
//===========================================================================
【问】2806 CAP和中断
全部回复(4)
正序查看
倒序查看
现在还没有回复呢,说说你的想法