最近在做一个项目,其中用到28062的ECAP3口做捕获,发现会间隔不定时间的不进入ECAP捕获中断。
本人是用ECAP捕获交流过零信号,其中ECAP设置捕获中断,在中断中用一个LED灯翻转指示。用示波器同时检测LED翻转指示信号和过零信号,发现过零信号有但是LED翻转信号会间隔丢失,即会出现偶尔的捕获失败,过零信号示波器显示是没有消失的,但是LED指示的信号却会在某个周期出现缺失。而且更严重会偶尔出现连续是三个过零捕获失败,已经验证多次现象,可以确定是捕获失败,过零信号一直有的。下面是我的配置,请各位大神给予指正,谢谢。
void InitECap3(void)
{
ECap3Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap3Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap3Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
ECap3Regs.ECCTL1.bit.PRESCALE = 0; // n*2分频
// Configure peripheral registers
ECap3Regs.ECCTL2.bit.CONT_ONESHT = 1; // One-shot
ECap3Regs.ECCTL2.bit.STOP_WRAP = 0; //3 // Stop at 1 events
ECap3Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap3Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap3Regs.ECCTL2.bit.SYNCI_EN = 1; // Enable sync in
ECap3Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap3Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap3Regs.ECEINT.bit.CEVT1 = 1; // 1 events = interrupt
}
interrupt void ecap3_isr(void)
{
dfreq = ECap3Regs.CAP1;
Run_Led_Inverse = 1;
ECap3Regs.ECCLR.bit.CEVT1 = 1;
ECap3Regs.ECCLR.bit.INT = 1;
ECap3Regs.ECCTL2.bit.REARM = 1;
// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
Green Deng:CAP部分配置没什么问题。现在有两点怀疑的,一是你的程序中还有没有其他优先级高的中断抢占了cap中断造成cap中断丢失。二是你的LED反转应该是用的GPIO控制的吧?你控制GPIO用的是哪个寄存器?
最近在做一个项目,其中用到28062的ECAP3口做捕获,发现会间隔不定时间的不进入ECAP捕获中断。
本人是用ECAP捕获交流过零信号,其中ECAP设置捕获中断,在中断中用一个LED灯翻转指示。用示波器同时检测LED翻转指示信号和过零信号,发现过零信号有但是LED翻转信号会间隔丢失,即会出现偶尔的捕获失败,过零信号示波器显示是没有消失的,但是LED指示的信号却会在某个周期出现缺失。而且更严重会偶尔出现连续是三个过零捕获失败,已经验证多次现象,可以确定是捕获失败,过零信号一直有的。下面是我的配置,请各位大神给予指正,谢谢。
void InitECap3(void)
{
ECap3Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap3Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap3Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
ECap3Regs.ECCTL1.bit.PRESCALE = 0; // n*2分频
// Configure peripheral registers
ECap3Regs.ECCTL2.bit.CONT_ONESHT = 1; // One-shot
ECap3Regs.ECCTL2.bit.STOP_WRAP = 0; //3 // Stop at 1 events
ECap3Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap3Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap3Regs.ECCTL2.bit.SYNCI_EN = 1; // Enable sync in
ECap3Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap3Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap3Regs.ECEINT.bit.CEVT1 = 1; // 1 events = interrupt
}
interrupt void ecap3_isr(void)
{
dfreq = ECap3Regs.CAP1;
Run_Led_Inverse = 1;
ECap3Regs.ECCLR.bit.CEVT1 = 1;
ECap3Regs.ECCLR.bit.INT = 1;
ECap3Regs.ECCTL2.bit.REARM = 1;
// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
user4383943:
回复 Green Deng:
非常感谢您的回复,中断肯定是有其他的。还有ECAP2中断,PWM中断(epwm2_timer_isr;epwm3_timer_isr),还有一些串口SCI中断,定时器中断等,但是按照我的理解,这个ECAP捕获不应该丢失,因为这个是20ms进来一次,其他的中断使用时间都是微秒级别,这个ECAP是属于硬件捕获(触发),软件上即使不能立马进入中断(假设被其他高优先级的中断抢占)也只是延时了一会,但是触发在硬件上已经产生,软件应该还是要进来的。关于那个寄存器我是翻转(#define Run_Led_InverseGpioDataRegs.GPBTOGGLE.bit.GPIO52),谢谢。
最近在做一个项目,其中用到28062的ECAP3口做捕获,发现会间隔不定时间的不进入ECAP捕获中断。
本人是用ECAP捕获交流过零信号,其中ECAP设置捕获中断,在中断中用一个LED灯翻转指示。用示波器同时检测LED翻转指示信号和过零信号,发现过零信号有但是LED翻转信号会间隔丢失,即会出现偶尔的捕获失败,过零信号示波器显示是没有消失的,但是LED指示的信号却会在某个周期出现缺失。而且更严重会偶尔出现连续是三个过零捕获失败,已经验证多次现象,可以确定是捕获失败,过零信号一直有的。下面是我的配置,请各位大神给予指正,谢谢。
void InitECap3(void)
{
ECap3Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap3Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap3Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
ECap3Regs.ECCTL1.bit.PRESCALE = 0; // n*2分频
// Configure peripheral registers
ECap3Regs.ECCTL2.bit.CONT_ONESHT = 1; // One-shot
ECap3Regs.ECCTL2.bit.STOP_WRAP = 0; //3 // Stop at 1 events
ECap3Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap3Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap3Regs.ECCTL2.bit.SYNCI_EN = 1; // Enable sync in
ECap3Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap3Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap3Regs.ECEINT.bit.CEVT1 = 1; // 1 events = interrupt
}
interrupt void ecap3_isr(void)
{
dfreq = ECap3Regs.CAP1;
Run_Led_Inverse = 1;
ECap3Regs.ECCLR.bit.CEVT1 = 1;
ECap3Regs.ECCLR.bit.INT = 1;
ECap3Regs.ECCTL2.bit.REARM = 1;
// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
Green Deng:
回复 user4383943:
因为你是通过观察GPIO的,能否观察寄存器的值呢?
另外,有没有用例程测试过CAP模块是否正常?
最近在做一个项目,其中用到28062的ECAP3口做捕获,发现会间隔不定时间的不进入ECAP捕获中断。
本人是用ECAP捕获交流过零信号,其中ECAP设置捕获中断,在中断中用一个LED灯翻转指示。用示波器同时检测LED翻转指示信号和过零信号,发现过零信号有但是LED翻转信号会间隔丢失,即会出现偶尔的捕获失败,过零信号示波器显示是没有消失的,但是LED指示的信号却会在某个周期出现缺失。而且更严重会偶尔出现连续是三个过零捕获失败,已经验证多次现象,可以确定是捕获失败,过零信号一直有的。下面是我的配置,请各位大神给予指正,谢谢。
void InitECap3(void)
{
ECap3Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap3Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap3Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
ECap3Regs.ECCTL1.bit.PRESCALE = 0; // n*2分频
// Configure peripheral registers
ECap3Regs.ECCTL2.bit.CONT_ONESHT = 1; // One-shot
ECap3Regs.ECCTL2.bit.STOP_WRAP = 0; //3 // Stop at 1 events
ECap3Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap3Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap3Regs.ECCTL2.bit.SYNCI_EN = 1; // Enable sync in
ECap3Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap3Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap3Regs.ECEINT.bit.CEVT1 = 1; // 1 events = interrupt
}
interrupt void ecap3_isr(void)
{
dfreq = ECap3Regs.CAP1;
Run_Led_Inverse = 1;
ECap3Regs.ECCLR.bit.CEVT1 = 1;
ECap3Regs.ECCLR.bit.INT = 1;
ECap3Regs.ECCTL2.bit.REARM = 1;
// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
user4383943:
回复 Green Deng:
是这样的,那个没用进ECAP中断还有其他的现象也是证明没用进入的,比如我是在那个外部循环20ms计数,在ECAP中断清零那个外部计数,确实会出现连续三次都没有被清零的。那个指示灯只是进一步证明没有翻转,因为就是在没有出现翻转,然后同时那个外部计数也没有被清零。这个不是每时每刻或者说很容易出现的,有的时候一个星期出现一次,有的时候半个月出现一次。我这个就是用来捕获市电过零的,外部就是通过那个计数三次连续没有被清,就报市电没有接入故障的,之前就是发现会无缘无故报市电没有接入故障,才发现这个ECAP口的问题,实际市电是一直存在的,这个可以确认的。
最近在做一个项目,其中用到28062的ECAP3口做捕获,发现会间隔不定时间的不进入ECAP捕获中断。
本人是用ECAP捕获交流过零信号,其中ECAP设置捕获中断,在中断中用一个LED灯翻转指示。用示波器同时检测LED翻转指示信号和过零信号,发现过零信号有但是LED翻转信号会间隔丢失,即会出现偶尔的捕获失败,过零信号示波器显示是没有消失的,但是LED指示的信号却会在某个周期出现缺失。而且更严重会偶尔出现连续是三个过零捕获失败,已经验证多次现象,可以确定是捕获失败,过零信号一直有的。下面是我的配置,请各位大神给予指正,谢谢。
void InitECap3(void)
{
ECap3Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap3Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap3Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
ECap3Regs.ECCTL1.bit.PRESCALE = 0; // n*2分频
// Configure peripheral registers
ECap3Regs.ECCTL2.bit.CONT_ONESHT = 1; // One-shot
ECap3Regs.ECCTL2.bit.STOP_WRAP = 0; //3 // Stop at 1 events
ECap3Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap3Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap3Regs.ECCTL2.bit.SYNCI_EN = 1; // Enable sync in
ECap3Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap3Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap3Regs.ECEINT.bit.CEVT1 = 1; // 1 events = interrupt
}
interrupt void ecap3_isr(void)
{
dfreq = ECap3Regs.CAP1;
Run_Led_Inverse = 1;
ECap3Regs.ECCLR.bit.CEVT1 = 1;
ECap3Regs.ECCLR.bit.INT = 1;
ECap3Regs.ECCTL2.bit.REARM = 1;
// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
user4383943:
回复 Green Deng:
是这样的。首先那个灯的指示是我进一步证明没有进入ECAP中断的辅证。先是发现不能进入ECAP中断,才在中断中进行灯的翻转,看是否确实没有进来。因为我是在其他地方发现没有进入ECAP中断,我在程序的外部循环中有个定时器20ms会计数增加一次,如果在60ms加了3次,那么就会报故障,报市电没有接入故障。我这个ECAP本来就是采集市电过零的,就是有时偶然会出现误报市电没有接入故障才发现这个问题,但是实际市电电压可以确认是有的,过零信号也是有的,都有用示波器监测的。这个误报或者说不进入也不是每时每刻经常进入,他有时一个星期有时2个星期甚至更久,我是持续放在那里运行,然后确实出现60ms连续三次没有清零外部计数,而我们的过零是20ms来一次(50HZ)。
最近在做一个项目,其中用到28062的ECAP3口做捕获,发现会间隔不定时间的不进入ECAP捕获中断。
本人是用ECAP捕获交流过零信号,其中ECAP设置捕获中断,在中断中用一个LED灯翻转指示。用示波器同时检测LED翻转指示信号和过零信号,发现过零信号有但是LED翻转信号会间隔丢失,即会出现偶尔的捕获失败,过零信号示波器显示是没有消失的,但是LED指示的信号却会在某个周期出现缺失。而且更严重会偶尔出现连续是三个过零捕获失败,已经验证多次现象,可以确定是捕获失败,过零信号一直有的。下面是我的配置,请各位大神给予指正,谢谢。
void InitECap3(void)
{
ECap3Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap3Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap3Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
ECap3Regs.ECCTL1.bit.PRESCALE = 0; // n*2分频
// Configure peripheral registers
ECap3Regs.ECCTL2.bit.CONT_ONESHT = 1; // One-shot
ECap3Regs.ECCTL2.bit.STOP_WRAP = 0; //3 // Stop at 1 events
ECap3Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap3Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap3Regs.ECCTL2.bit.SYNCI_EN = 1; // Enable sync in
ECap3Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap3Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap3Regs.ECEINT.bit.CEVT1 = 1; // 1 events = interrupt
}
interrupt void ecap3_isr(void)
{
dfreq = ECap3Regs.CAP1;
Run_Led_Inverse = 1;
ECap3Regs.ECCLR.bit.CEVT1 = 1;
ECap3Regs.ECCLR.bit.INT = 1;
ECap3Regs.ECCTL2.bit.REARM = 1;
// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
Green Deng:
回复 user4383943:
大概能理解你的思路,就是用cap中断清零计数器,3次未清零则认为是cap没有接收中断从而报错。不过我看你的cap配置确实没看出来问题,而且基本跟例程的一样。目前没有什么想法,推荐你升级到E2E英文论坛咨询一下这个问题:
e2e.ti.com/…/171
最近在做一个项目,其中用到28062的ECAP3口做捕获,发现会间隔不定时间的不进入ECAP捕获中断。
本人是用ECAP捕获交流过零信号,其中ECAP设置捕获中断,在中断中用一个LED灯翻转指示。用示波器同时检测LED翻转指示信号和过零信号,发现过零信号有但是LED翻转信号会间隔丢失,即会出现偶尔的捕获失败,过零信号示波器显示是没有消失的,但是LED指示的信号却会在某个周期出现缺失。而且更严重会偶尔出现连续是三个过零捕获失败,已经验证多次现象,可以确定是捕获失败,过零信号一直有的。下面是我的配置,请各位大神给予指正,谢谢。
void InitECap3(void)
{
ECap3Regs.ECEINT.all = 0x0000; // Disable all capture interrupts
ECap3Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags
ECap3Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped
ECap3Regs.ECCTL1.bit.PRESCALE = 0; // n*2分频
// Configure peripheral registers
ECap3Regs.ECCTL2.bit.CONT_ONESHT = 1; // One-shot
ECap3Regs.ECCTL2.bit.STOP_WRAP = 0; //3 // Stop at 1 events
ECap3Regs.ECCTL1.bit.CAP1POL = 1; // Falling edge
ECap3Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap3Regs.ECCTL2.bit.SYNCI_EN = 1; // Enable sync in
ECap3Regs.ECCTL2.bit.SYNCO_SEL = 0; // Pass through
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap3Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap3Regs.ECCTL2.bit.REARM = 1; // arm one-shot
ECap3Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads
ECap3Regs.ECEINT.bit.CEVT1 = 1; // 1 events = interrupt
}
interrupt void ecap3_isr(void)
{
dfreq = ECap3Regs.CAP1;
Run_Led_Inverse = 1;
ECap3Regs.ECCLR.bit.CEVT1 = 1;
ECap3Regs.ECCLR.bit.INT = 1;
ECap3Regs.ECCTL2.bit.REARM = 1;
// Acknowledge this interrupt to receive more interrupts from group 4
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
user4383943:
回复 Green Deng:
好的,谢谢