求DSPC2000 F28027eCAP完整项目文件

2019-08-01 16:53发布

在论坛找了一个eCAP程序,改了一下,结果进不了中断,而且GPIO19脚还是高电平,求解决
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
10条回答
wangjinlili
2019-08-01 22:34
高电平,求解决,代码如下:
void InitECapture()
{
   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;  //CAP mode
   ECap1Regs.ECCTL2.bit.CONT_ONESHT = 0; // continuous mode
   ECap1Regs.ECCTL2.bit.STOP_WRAP = 1;   // Stop at 2 events
   ECap1Regs.ECCTL1.bit.PRESCALE = 0;    // Divide by 1
   ECap1Regs.ECCTL1.bit.CAP1POL = 0;          // Rising edge
   ECap1Regs.ECCTL1.bit.CAP2POL = 0;          // Rising edge
   ECap1Regs.ECCTL1.bit.CTRRST1 = 1;          // Difference operation
   ECap1Regs.ECCTL1.bit.CTRRST2 = 0;          // Difference operation
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Enable sync in
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 3;        //  Disable sync out signal
   ECap1Regs.ECCTL1.bit.CAPLDEN = 1;          // Enable capture units
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1;        // Start Counter
   ECap1Regs.ECEINT.bit.CEVT2 = 1;            // 2 events = interrupt
}
void main(void)
{
   InitSysCtrl();
   EALLOW;    //允许访问受保护的空间
      GpioCtrlRegs.GPADIR.bit.GPIO1=1;
      GpioDataRegs.GPADAT.bit.GPIO1=1;
      EDIS;
      InitECap1Gpio();
      InitECapture();
      EALLOW;  // This is needed to write to EALLOW protected registers
      PieVectTable.ECAP1_INT = &ecap1_isr;
      EDIS; // This is needed to disable write to EALLOW protected registers  // Enable CPU INT4 which is connected to ECAP1-4 INT:
      IER |= M_INT4;
      PieCtrlRegs.PIEIER4.bit.INTx1 = 1;
      // Enable eCAP INTn in the PIE: Group 3 interrupt 1-6
      EINT;   // Enable Global interrupt INTM
      ERTM;   // Enable Global realtime interrupt DBGM
      while(1);
}
interrupt void ecap1_isr(void)
{
//ECap1Count = ECap1Regs.CAP1;
   ECap2Count = ECap1Regs.CAP2;
   GpioDataRegs.GPADAT.bit.GPIO1=0;
//ECap1Regs.ECCLR.all = 0xFFFF;
   ECap1Regs.ECCLR.bit.CEVT2 = 1;
   ECap1Regs.ECCLR.bit.CEVT1 = 1;
   ECap1Regs.ECCLR.bit.INT = 1;
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;

}

一周热门 更多>