利用28335的cap5捕获23kHz左右的频率,但是无法进入到中断,请问程序上哪里有问题?
GpioCtrlRegs.GPBPUD.bit.GPIO48 = 0; //
GpioCtrlRegs.GPBMUX2.bit.GPIO48 = 1; // ecap
GpioCtrlRegs.GPBQSEL2.bit.GPIO48 = 0; // 使cap5时钟与系统时钟输出同步
ECap5Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap5Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap5Regs.ECCTL1.bit.PRESCALE = 0; //对外部信号不分频
ECap5Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap5Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
// Configure peripheral registers
ECap5Regs.ECCTL2.bit.CONT_ONESHT = 0; // continuous mode
ECap5Regs.ECCTL2.bit.STOP_WRAP = 3; // Stop at 4 events
ECap5Regs.ECCTL1.bit.CAP1POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP2POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP3POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP4POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CTRRST1 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST2 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST3 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST4 = 0; // Difference operation
ECap5Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap5Regs.ECCTL2.bit.SYNCO_SEL = 2; // Pass through
ECap5Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap5Regs.ECCTL2.bit.CAP_APWM =0;
ECap5Regs.ECEINT.bit.CEVT4 = 1; // 4 events = interrupt
ECap5Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
//ECap5Regs.ECCTL2.bit.REARM = 1; // arm one-shot
EALLOW;
PieVectTable.ECAP5_INT = &Ecap5_isr;
EDIS;
PieCtrlRegs.PIEIER4.bit.INTx5 = 1;
IER |= M_INT4 ;
EALLOW;
SysCtrlRegs.PCLKCR1.bit.ECAP5ENCLK=1;
EDIS;
万分感谢!
Brian Wang0:
建议查询一下标志位,看看能否置位
利用28335的cap5捕获23kHz左右的频率,但是无法进入到中断,请问程序上哪里有问题?
GpioCtrlRegs.GPBPUD.bit.GPIO48 = 0; //
GpioCtrlRegs.GPBMUX2.bit.GPIO48 = 1; // ecap
GpioCtrlRegs.GPBQSEL2.bit.GPIO48 = 0; // 使cap5时钟与系统时钟输出同步
ECap5Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap5Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap5Regs.ECCTL1.bit.PRESCALE = 0; //对外部信号不分频
ECap5Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap5Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
// Configure peripheral registers
ECap5Regs.ECCTL2.bit.CONT_ONESHT = 0; // continuous mode
ECap5Regs.ECCTL2.bit.STOP_WRAP = 3; // Stop at 4 events
ECap5Regs.ECCTL1.bit.CAP1POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP2POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP3POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP4POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CTRRST1 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST2 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST3 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST4 = 0; // Difference operation
ECap5Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap5Regs.ECCTL2.bit.SYNCO_SEL = 2; // Pass through
ECap5Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap5Regs.ECCTL2.bit.CAP_APWM =0;
ECap5Regs.ECEINT.bit.CEVT4 = 1; // 4 events = interrupt
ECap5Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
//ECap5Regs.ECCTL2.bit.REARM = 1; // arm one-shot
EALLOW;
PieVectTable.ECAP5_INT = &Ecap5_isr;
EDIS;
PieCtrlRegs.PIEIER4.bit.INTx5 = 1;
IER |= M_INT4 ;
EALLOW;
SysCtrlRegs.PCLKCR1.bit.ECAP5ENCLK=1;
EDIS;
万分感谢!
zikai chen:
回复 Brian Wang0:
单步执行完上面的程序后,ECAP5的所有寄存器值仍然是0,程序就上面那部分。
利用28335的cap5捕获23kHz左右的频率,但是无法进入到中断,请问程序上哪里有问题?
GpioCtrlRegs.GPBPUD.bit.GPIO48 = 0; //
GpioCtrlRegs.GPBMUX2.bit.GPIO48 = 1; // ecap
GpioCtrlRegs.GPBQSEL2.bit.GPIO48 = 0; // 使cap5时钟与系统时钟输出同步
ECap5Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap5Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap5Regs.ECCTL1.bit.PRESCALE = 0; //对外部信号不分频
ECap5Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap5Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
// Configure peripheral registers
ECap5Regs.ECCTL2.bit.CONT_ONESHT = 0; // continuous mode
ECap5Regs.ECCTL2.bit.STOP_WRAP = 3; // Stop at 4 events
ECap5Regs.ECCTL1.bit.CAP1POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP2POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP3POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP4POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CTRRST1 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST2 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST3 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST4 = 0; // Difference operation
ECap5Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap5Regs.ECCTL2.bit.SYNCO_SEL = 2; // Pass through
ECap5Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap5Regs.ECCTL2.bit.CAP_APWM =0;
ECap5Regs.ECEINT.bit.CEVT4 = 1; // 4 events = interrupt
ECap5Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
//ECap5Regs.ECCTL2.bit.REARM = 1; // arm one-shot
EALLOW;
PieVectTable.ECAP5_INT = &Ecap5_isr;
EDIS;
PieCtrlRegs.PIEIER4.bit.INTx5 = 1;
IER |= M_INT4 ;
EALLOW;
SysCtrlRegs.PCLKCR1.bit.ECAP5ENCLK=1;
EDIS;
万分感谢!
Seven Han:
回复 zikai chen:
建议您参考controlSUITE里ECAP例程的配置,你的全局中断有打开吗?
利用28335的cap5捕获23kHz左右的频率,但是无法进入到中断,请问程序上哪里有问题?
GpioCtrlRegs.GPBPUD.bit.GPIO48 = 0; //
GpioCtrlRegs.GPBMUX2.bit.GPIO48 = 1; // ecap
GpioCtrlRegs.GPBQSEL2.bit.GPIO48 = 0; // 使cap5时钟与系统时钟输出同步
ECap5Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap5Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap5Regs.ECCTL1.bit.PRESCALE = 0; //对外部信号不分频
ECap5Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap5Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
// Configure peripheral registers
ECap5Regs.ECCTL2.bit.CONT_ONESHT = 0; // continuous mode
ECap5Regs.ECCTL2.bit.STOP_WRAP = 3; // Stop at 4 events
ECap5Regs.ECCTL1.bit.CAP1POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP2POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP3POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CAP4POL = 0; // Rising edge
ECap5Regs.ECCTL1.bit.CTRRST1 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST2 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST3 = 0; // Difference operation
ECap5Regs.ECCTL1.bit.CTRRST4 = 0; // Difference operation
ECap5Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap5Regs.ECCTL2.bit.SYNCO_SEL = 2; // Pass through
ECap5Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap5Regs.ECCTL2.bit.CAP_APWM =0;
ECap5Regs.ECEINT.bit.CEVT4 = 1; // 4 events = interrupt
ECap5Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
//ECap5Regs.ECCTL2.bit.REARM = 1; // arm one-shot
EALLOW;
PieVectTable.ECAP5_INT = &Ecap5_isr;
EDIS;
PieCtrlRegs.PIEIER4.bit.INTx5 = 1;
IER |= M_INT4 ;
EALLOW;
SysCtrlRegs.PCLKCR1.bit.ECAP5ENCLK=1;
EDIS;
万分感谢!
zikai chen:
回复 Seven Han:
跟配置没关系,中断也有开,关键是配置了CAP5的寄存器,单步执行后,发现寄存器的值都没变,始终为0.