TI中文支持网
TI专业的中文技术问题搜集分享网站

28035 Ecap如何设置可以使上升沿和下降沿同时触发一个中断ECAP1_INT?

我在用GPIO24作为Ecap时,只能使其上升沿触发中断ECAP1_INT,或下降沿触发ECAP1_INT,怎么就不能二者都触发中断ECAP1_INT?

求各位能否给出个代码的例子,我的例子贴出来,看看怎么修改?

1、初始化

 EALLOW;                       // Enable EALLOW
 // Set up the ECAP1 pin to primary function
 GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;//上拉
 GpioCtrlRegs.GPADIR.bit.GPIO24 = 0; //输入
 GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; //
 GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;  // GPIO24 is ECAP1
 EDIS;                         // Disable EALLOW

   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts
   ECap1Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags
   ECap1Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped

   // Configure peripheral registers
   ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //Ecap模式
   ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1;      // one shot mode
   ECap1Regs.ECCTL2.bit.STOP_WRAP = 1;        // Stop at 2 events

   //ECap1Regs.ECCTL1.bit.CAP1POL = 1;          // Falling edge
   ECap1Regs.ECCTL1.bit.CAP2POL = 0;          // Rising edge
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync in
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;   //Disable sync out
   ECap1Regs.ECCTL2.bit.REARM = 1;            // arm one-shot
   //ECap1Regs.ECEINT.bit.CEVT1 = 1;            // 1st events = interrupt
   ECap1Regs.ECEINT.bit.CEVT2 = 1;            // 2st events = interrupt

2、开中断

   EALLOW; 

   PieVectTable.ECAP1_INT = &ecap1_isr;
   EDIS;
   IER |= M_INT4;
   PieCtrlRegs.PIEIER4.bit.INTx1 = 1;

3、中断函数

interrupt void ecap1_isr(void)
{
    GpioDataRegs.GPATOGGLE.bit.GPIO6 ^=1; //用来测试中断跳变和外部信号是否一致
    //ECap1Regs.ECCLR.bit.CEVT1 = 1;
    ECap1Regs.ECCLR.bit.CEVT2 = 1;
    ECap1Regs.ECCLR.bit.INT = 1;
    ECap1Regs.ECCTL2.bit.REARM = 1;
    // Acknowledge this interrupt to receive more interrupts from group 4
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

Young Hu:

建议您参考eCap_ePWM的例程修改

我在用GPIO24作为Ecap时,只能使其上升沿触发中断ECAP1_INT,或下降沿触发ECAP1_INT,怎么就不能二者都触发中断ECAP1_INT?

求各位能否给出个代码的例子,我的例子贴出来,看看怎么修改?

1、初始化

 EALLOW;                       // Enable EALLOW
 // Set up the ECAP1 pin to primary function
 GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;//上拉
 GpioCtrlRegs.GPADIR.bit.GPIO24 = 0; //输入
 GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; //
 GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;  // GPIO24 is ECAP1
 EDIS;                         // Disable EALLOW

   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts
   ECap1Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags
   ECap1Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped

   // Configure peripheral registers
   ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //Ecap模式
   ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1;      // one shot mode
   ECap1Regs.ECCTL2.bit.STOP_WRAP = 1;        // Stop at 2 events

   //ECap1Regs.ECCTL1.bit.CAP1POL = 1;          // Falling edge
   ECap1Regs.ECCTL1.bit.CAP2POL = 0;          // Rising edge
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync in
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;   //Disable sync out
   ECap1Regs.ECCTL2.bit.REARM = 1;            // arm one-shot
   //ECap1Regs.ECEINT.bit.CEVT1 = 1;            // 1st events = interrupt
   ECap1Regs.ECEINT.bit.CEVT2 = 1;            // 2st events = interrupt

2、开中断

   EALLOW; 

   PieVectTable.ECAP1_INT = &ecap1_isr;
   EDIS;
   IER |= M_INT4;
   PieCtrlRegs.PIEIER4.bit.INTx1 = 1;

3、中断函数

interrupt void ecap1_isr(void)
{
    GpioDataRegs.GPATOGGLE.bit.GPIO6 ^=1; //用来测试中断跳变和外部信号是否一致
    //ECap1Regs.ECCLR.bit.CEVT1 = 1;
    ECap1Regs.ECCLR.bit.CEVT2 = 1;
    ECap1Regs.ECCLR.bit.INT = 1;
    ECap1Regs.ECCTL2.bit.REARM = 1;
    // Acknowledge this interrupt to receive more interrupts from group 4
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

Rogers:

回复 Eric Ma:

我在用GPIO24作为Ecap时,只能使其上升沿触发中断ECAP1_INT,或下降沿触发ECAP1_INT,怎么就不能二者都触发中断ECAP1_INT?

求各位能否给出个代码的例子,我的例子贴出来,看看怎么修改?

1、初始化

 EALLOW;                       // Enable EALLOW
 // Set up the ECAP1 pin to primary function
 GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;//上拉
 GpioCtrlRegs.GPADIR.bit.GPIO24 = 0; //输入
 GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; //
 GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;  // GPIO24 is ECAP1
 EDIS;                         // Disable EALLOW

   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts
   ECap1Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags
   ECap1Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped

   // Configure peripheral registers
   ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //Ecap模式
   ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1;      // one shot mode
   ECap1Regs.ECCTL2.bit.STOP_WRAP = 1;        // Stop at 2 events

   //ECap1Regs.ECCTL1.bit.CAP1POL = 1;          // Falling edge
   ECap1Regs.ECCTL1.bit.CAP2POL = 0;          // Rising edge
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync in
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;   //Disable sync out
   ECap1Regs.ECCTL2.bit.REARM = 1;            // arm one-shot
   //ECap1Regs.ECEINT.bit.CEVT1 = 1;            // 1st events = interrupt
   ECap1Regs.ECEINT.bit.CEVT2 = 1;            // 2st events = interrupt

2、开中断

   EALLOW; 

   PieVectTable.ECAP1_INT = &ecap1_isr;
   EDIS;
   IER |= M_INT4;
   PieCtrlRegs.PIEIER4.bit.INTx1 = 1;

3、中断函数

interrupt void ecap1_isr(void)
{
    GpioDataRegs.GPATOGGLE.bit.GPIO6 ^=1; //用来测试中断跳变和外部信号是否一致
    //ECap1Regs.ECCLR.bit.CEVT1 = 1;
    ECap1Regs.ECCLR.bit.CEVT2 = 1;
    ECap1Regs.ECCLR.bit.INT = 1;
    ECap1Regs.ECCTL2.bit.REARM = 1;
    // Acknowledge this interrupt to receive more interrupts from group 4
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

Rogers:

回复 Eric Ma:

Thanks Eric:

你说的这种设置我已经设置了,如  

  ECap1Regs.ECEINT.bit.CEVT1 = 1;            // 1st events = interrupt   ECap1Regs.ECEINT.bit.CEVT2 = 1;            // 2st events = interrupt

但是还是只能触发事件CEVT1中断,我不知道在设置双边沿触发时,oneshot模式和continuous模式会不会有影响,请问有没有一个设置双边沿触发的例子?

我在用GPIO24作为Ecap时,只能使其上升沿触发中断ECAP1_INT,或下降沿触发ECAP1_INT,怎么就不能二者都触发中断ECAP1_INT?

求各位能否给出个代码的例子,我的例子贴出来,看看怎么修改?

1、初始化

 EALLOW;                       // Enable EALLOW
 // Set up the ECAP1 pin to primary function
 GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;//上拉
 GpioCtrlRegs.GPADIR.bit.GPIO24 = 0; //输入
 GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; //
 GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;  // GPIO24 is ECAP1
 EDIS;                         // Disable EALLOW

   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts
   ECap1Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags
   ECap1Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped

   // Configure peripheral registers
   ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //Ecap模式
   ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1;      // one shot mode
   ECap1Regs.ECCTL2.bit.STOP_WRAP = 1;        // Stop at 2 events

   //ECap1Regs.ECCTL1.bit.CAP1POL = 1;          // Falling edge
   ECap1Regs.ECCTL1.bit.CAP2POL = 0;          // Rising edge
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync in
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;   //Disable sync out
   ECap1Regs.ECCTL2.bit.REARM = 1;            // arm one-shot
   //ECap1Regs.ECEINT.bit.CEVT1 = 1;            // 1st events = interrupt
   ECap1Regs.ECEINT.bit.CEVT2 = 1;            // 2st events = interrupt

2、开中断

   EALLOW; 

   PieVectTable.ECAP1_INT = &ecap1_isr;
   EDIS;
   IER |= M_INT4;
   PieCtrlRegs.PIEIER4.bit.INTx1 = 1;

3、中断函数

interrupt void ecap1_isr(void)
{
    GpioDataRegs.GPATOGGLE.bit.GPIO6 ^=1; //用来测试中断跳变和外部信号是否一致
    //ECap1Regs.ECCLR.bit.CEVT1 = 1;
    ECap1Regs.ECCLR.bit.CEVT2 = 1;
    ECap1Regs.ECCLR.bit.INT = 1;
    ECap1Regs.ECCTL2.bit.REARM = 1;
    // Acknowledge this interrupt to receive more interrupts from group 4
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

Rogers:

回复 Young Hu:

谢谢您的提示,我也是看过了,但该例程是在产生第四个事件时才触发中断,并没有设置成双边沿触发中断,还是有区别,您有设置成双边沿触发中断的代码例子吗??

我在用GPIO24作为Ecap时,只能使其上升沿触发中断ECAP1_INT,或下降沿触发ECAP1_INT,怎么就不能二者都触发中断ECAP1_INT?

求各位能否给出个代码的例子,我的例子贴出来,看看怎么修改?

1、初始化

 EALLOW;                       // Enable EALLOW
 // Set up the ECAP1 pin to primary function
 GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;//上拉
 GpioCtrlRegs.GPADIR.bit.GPIO24 = 0; //输入
 GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; //
 GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;  // GPIO24 is ECAP1
 EDIS;                         // Disable EALLOW

   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts
   ECap1Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags
   ECap1Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped

   // Configure peripheral registers
   ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //Ecap模式
   ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1;      // one shot mode
   ECap1Regs.ECCTL2.bit.STOP_WRAP = 1;        // Stop at 2 events

   //ECap1Regs.ECCTL1.bit.CAP1POL = 1;          // Falling edge
   ECap1Regs.ECCTL1.bit.CAP2POL = 0;          // Rising edge
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync in
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;   //Disable sync out
   ECap1Regs.ECCTL2.bit.REARM = 1;            // arm one-shot
   //ECap1Regs.ECEINT.bit.CEVT1 = 1;            // 1st events = interrupt
   ECap1Regs.ECEINT.bit.CEVT2 = 1;            // 2st events = interrupt

2、开中断

   EALLOW; 

   PieVectTable.ECAP1_INT = &ecap1_isr;
   EDIS;
   IER |= M_INT4;
   PieCtrlRegs.PIEIER4.bit.INTx1 = 1;

3、中断函数

interrupt void ecap1_isr(void)
{
    GpioDataRegs.GPATOGGLE.bit.GPIO6 ^=1; //用来测试中断跳变和外部信号是否一致
    //ECap1Regs.ECCLR.bit.CEVT1 = 1;
    ECap1Regs.ECCLR.bit.CEVT2 = 1;
    ECap1Regs.ECCLR.bit.INT = 1;
    ECap1Regs.ECCTL2.bit.REARM = 1;
    // Acknowledge this interrupt to receive more interrupts from group 4
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

Rogers:

回复 Eric Ma:

Eric:

发现我设置了强制中断事件就可以双边沿触发了:

  if(test1)  {   ECap1Regs.ECFRC.bit.CEVT1=1;   test1=0;  }  else  {   ECap1Regs.ECFRC.bit.CEVT2=1;   test1=1;  }

这个代码在100us的定时中断中执行,这样强制了之后,就能两个事件都触发外部中断,但是我用实际的一路HALL信号触发时,只能在单边沿触发中断,不知何解?

 

我在用GPIO24作为Ecap时,只能使其上升沿触发中断ECAP1_INT,或下降沿触发ECAP1_INT,怎么就不能二者都触发中断ECAP1_INT?

求各位能否给出个代码的例子,我的例子贴出来,看看怎么修改?

1、初始化

 EALLOW;                       // Enable EALLOW
 // Set up the ECAP1 pin to primary function
 GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;//上拉
 GpioCtrlRegs.GPADIR.bit.GPIO24 = 0; //输入
 GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; //
 GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;  // GPIO24 is ECAP1
 EDIS;                         // Disable EALLOW

   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts
   ECap1Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags
   ECap1Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped

   // Configure peripheral registers
   ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //Ecap模式
   ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1;      // one shot mode
   ECap1Regs.ECCTL2.bit.STOP_WRAP = 1;        // Stop at 2 events

   //ECap1Regs.ECCTL1.bit.CAP1POL = 1;          // Falling edge
   ECap1Regs.ECCTL1.bit.CAP2POL = 0;          // Rising edge
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync in
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;   //Disable sync out
   ECap1Regs.ECCTL2.bit.REARM = 1;            // arm one-shot
   //ECap1Regs.ECEINT.bit.CEVT1 = 1;            // 1st events = interrupt
   ECap1Regs.ECEINT.bit.CEVT2 = 1;            // 2st events = interrupt

2、开中断

   EALLOW; 

   PieVectTable.ECAP1_INT = &ecap1_isr;
   EDIS;
   IER |= M_INT4;
   PieCtrlRegs.PIEIER4.bit.INTx1 = 1;

3、中断函数

interrupt void ecap1_isr(void)
{
    GpioDataRegs.GPATOGGLE.bit.GPIO6 ^=1; //用来测试中断跳变和外部信号是否一致
    //ECap1Regs.ECCLR.bit.CEVT1 = 1;
    ECap1Regs.ECCLR.bit.CEVT2 = 1;
    ECap1Regs.ECCLR.bit.INT = 1;
    ECap1Regs.ECCTL2.bit.REARM = 1;
    // Acknowledge this interrupt to receive more interrupts from group 4
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

Rogers:

回复 Eric Ma:

Thanks Eric:

我就得更改计算方法了,嘿嘿,真心的感谢你的支持!!!

我在用GPIO24作为Ecap时,只能使其上升沿触发中断ECAP1_INT,或下降沿触发ECAP1_INT,怎么就不能二者都触发中断ECAP1_INT?

求各位能否给出个代码的例子,我的例子贴出来,看看怎么修改?

1、初始化

 EALLOW;                       // Enable EALLOW
 // Set up the ECAP1 pin to primary function
 GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;//上拉
 GpioCtrlRegs.GPADIR.bit.GPIO24 = 0; //输入
 GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; //
 GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;  // GPIO24 is ECAP1
 EDIS;                         // Disable EALLOW

   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts
   ECap1Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags
   ECap1Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped

   // Configure peripheral registers
   ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //Ecap模式
   ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1;      // one shot mode
   ECap1Regs.ECCTL2.bit.STOP_WRAP = 1;        // Stop at 2 events

   //ECap1Regs.ECCTL1.bit.CAP1POL = 1;          // Falling edge
   ECap1Regs.ECCTL1.bit.CAP2POL = 0;          // Rising edge
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync in
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;   //Disable sync out
   ECap1Regs.ECCTL2.bit.REARM = 1;            // arm one-shot
   //ECap1Regs.ECEINT.bit.CEVT1 = 1;            // 1st events = interrupt
   ECap1Regs.ECEINT.bit.CEVT2 = 1;            // 2st events = interrupt

2、开中断

   EALLOW; 

   PieVectTable.ECAP1_INT = &ecap1_isr;
   EDIS;
   IER |= M_INT4;
   PieCtrlRegs.PIEIER4.bit.INTx1 = 1;

3、中断函数

interrupt void ecap1_isr(void)
{
    GpioDataRegs.GPATOGGLE.bit.GPIO6 ^=1; //用来测试中断跳变和外部信号是否一致
    //ECap1Regs.ECCLR.bit.CEVT1 = 1;
    ECap1Regs.ECCLR.bit.CEVT2 = 1;
    ECap1Regs.ECCLR.bit.INT = 1;
    ECap1Regs.ECCTL2.bit.REARM = 1;
    // Acknowledge this interrupt to receive more interrupts from group 4
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

Mary Hu:

您好!我遇到了类似的问题,偶然看到了你们的讨论。受益匪浅。请问,最后您的问题是怎么解决的呢?

我有个问题想请教您!

我现在用dsp控制无刷直流电机,需要cap捕获三路霍尔位置信号来进行电子换相。这样的话,必须使每路信号的上升沿和下降沿触发中断啊!怎么解决呢?

期待您的解答,谢谢您!

我在用GPIO24作为Ecap时,只能使其上升沿触发中断ECAP1_INT,或下降沿触发ECAP1_INT,怎么就不能二者都触发中断ECAP1_INT?

求各位能否给出个代码的例子,我的例子贴出来,看看怎么修改?

1、初始化

 EALLOW;                       // Enable EALLOW
 // Set up the ECAP1 pin to primary function
 GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;//上拉
 GpioCtrlRegs.GPADIR.bit.GPIO24 = 0; //输入
 GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0; //
 GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;  // GPIO24 is ECAP1
 EDIS;                         // Disable EALLOW

   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts
   ECap1Regs.ECCLR.all = 0xFFFF;              // Clear all CAP interrupt flags
   ECap1Regs.ECCTL1.bit.CAPLDEN = 0;          // Disable CAP1-CAP4 register loads
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0;        // Make sure the counter is stopped

   // Configure peripheral registers
   ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //Ecap模式
   ECap1Regs.ECCTL2.bit.CONT_ONESHT = 1;      // one shot mode
   ECap1Regs.ECCTL2.bit.STOP_WRAP = 1;        // Stop at 2 events

   //ECap1Regs.ECCTL1.bit.CAP1POL = 1;          // Falling edge
   ECap1Regs.ECCTL1.bit.CAP2POL = 0;          // Rising edge
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync in
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;   //Disable sync out
   ECap1Regs.ECCTL2.bit.REARM = 1;            // arm one-shot
   //ECap1Regs.ECEINT.bit.CEVT1 = 1;            // 1st events = interrupt
   ECap1Regs.ECEINT.bit.CEVT2 = 1;            // 2st events = interrupt

2、开中断

   EALLOW; 

   PieVectTable.ECAP1_INT = &ecap1_isr;
   EDIS;
   IER |= M_INT4;
   PieCtrlRegs.PIEIER4.bit.INTx1 = 1;

3、中断函数

interrupt void ecap1_isr(void)
{
    GpioDataRegs.GPATOGGLE.bit.GPIO6 ^=1; //用来测试中断跳变和外部信号是否一致
    //ECap1Regs.ECCLR.bit.CEVT1 = 1;
    ECap1Regs.ECCLR.bit.CEVT2 = 1;
    ECap1Regs.ECCLR.bit.INT = 1;
    ECap1Regs.ECCTL2.bit.REARM = 1;
    // Acknowledge this interrupt to receive more interrupts from group 4
    PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}

liming Liu:

回复 Mary Hu:

好久没搞电机了,貌似不用上升沿和下降沿都做触发吧,电机的转速又不均匀的,HALL出来的也不是方波,检测三相HALL的上升沿不就好了么!

仅供参考!

赞(0)
未经允许不得转载:TI中文支持网 » 28035 Ecap如何设置可以使上升沿和下降沿同时触发一个中断ECAP1_INT?
分享到: 更多 (0)