This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28335 - Using eCap as APWM-interrupt-source

Hi @ all,

I want to use the eCap as an interrupt source in APWM mode. I want to generate an periodical interrupt, if the timebase counter is equal the period register (CTR==PRD).

With the following configuration, I get !two! interrupts:

Configuration of the periphals:

   ECap1Regs.ECEINT.all = 0x0000;             // Disable all capture interrupts
   ECap1Regs.ECCLR.all = 0xFF;              // Clear all CAP interrupt flags
   ECap1Regs.CTRPHS=0;                  // Set phase to zero
   ECap1Regs.ECCTL1.all = 0;          // Disable ECCTL1
   ECap1Regs.ECCTL2.all = 0;        // Stop the counter and disable all
  
    // Configure peripheral registers        
   ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;         // Disable sync in
   ECap1Regs.ECCTL2.bit.SYNCO_SEL = 3;       // Disable sync out
   ECap1Regs.ECCTL2.bit.CAP_APWM=1;            // Set APWM Mode
   ECap1Regs.ECEINT.bit.CTR_EQ_PRD=1;        // Enable int @ CTR==PRD
   ECap1Regs.CAP1=10000;                    // Load periode register
   ECap1Regs.ECCTL2.bit.TSCTRSTOP=1;    // Start the counter

In the ISR:

     ECap1Regs.ECCLR.bit.INT = 1;    // Clear the ECAP1 interrupt flag
    ECap1Regs.ECCLR.all = 0xFF;        // Clear all ECAP interrupt flags

 

The first interrupt occur when the counter is equal to the period register. The second interrupt occur 250 ns after the first (CTR==PRD) interrupt. And I don't know why the second interrupt occur!

I hope someone could say me what's wrong with this configuartion.

 

With best regards,

Chris


Here you can find the whole configuration (main):

2234.eCap_Config.txt
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "DSP28x_Project.h"
void initPeriphals(void);
interrupt void ecap1_isr(void);
void main(void)
{
InitSysCtrl();
// Disable CPU interrupts
DINT;
// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

 

  • Hi @ all,

    I think I figured out the problem.

    Just have a look at the ISR:

    First I have to clear the eCap interrupt flag and after that I have to clear the "normal" interrupt flag.

    And now the ISR looks like:


        ECap1Regs.ECCLR.bit.CTR_EQ_PRD = 1;      
        ECap1Regs.ECCLR.bit.INT = 1; 

     

    A stupid mistake! ;)

     

    Cheers

    Chris