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.

CCS/TMS320C6745: Generate Interrupt using eCAP module in APWM Mode

Part Number: TMS320C6745


Tool/software: Code Composer Studio

Hi,

I have written code for interrupt generate using APWM in eCAP. Code should generate interrupt when TSCTR reaches to APRD and then generate Flag on corresponding bit on ECFLG register. However it is found that Flag bit for APRD always equal to 1 even though Flag cleared in ISR sub routine. I have executed following code. Can anyone resolve my problem.

/*-------------Generate Interrupt using eCAP module in APWM Mode-------------*/

#define Uint32 unsigned int;
#define TSCTR (Uint32 *)0x01F08000;
#define CTRPHS (Uint32 *)0x01F08004;
#define CAP1 (Uint32 *)0x01F08008;
#define CAP2 (Uint32 *)0x01F0800C;
#define CAP3 (Uint32 *)0x01F08010;
#define CAP4 (Uint32 *)0x01F08014;
#define ECCTL1 (Uint32 *)0x01F08028;
#define ECCTL2 (Uint32 *)0x01F0802A;
#define ECEINT (Uint32 *)0x01F0802C;
#define ECFLG (Uint32 *)0x01F0802E;
#define ECCLR (Uint32 *)0x01F08030;
#define ECFRC (Uint32 *)0x01F08032;


void Init_APWM();
void APWM_ISR();


void main()
{

Uint32 *ECFLG;

Init_APWM(); // Intialize eCAP in APWM mode.
while (*ECFLG >> 1 & 1)   // Check weather Flag bit one or not.
{
APWM_ISR(); // Interrupt service routine.
/* Call GPIO pins */
}
}


void Init_APWM(void)
{

Uint32 *TSCTR,*CTRPHS,*CAP1,*CAP2,*CAP3,*CAP4,*ECCTL1,*ECCTL2,*ECEINT,*ECFLG,*ECCLR,*ECFRC;


*ECEINT = 0x0000; // Disable all interrupts
*ECCLR = 0x00FF; // Clear all interrupt flags
*CTRPHS = 0x00000000; // Set Phase to zero
*ECCTL1 = 0x0000; // Disable ECCTL1
*ECCTL2 = 0x0000; // Stop the counter and Disable ECCTL2

/* Configure peripheral registers */
*ECCTL2 = 1 << 9; // Set APWM Mode bit.CAP_APWM
*ECCTL2 = 0 << 5; // Disable sync in bit.SYNCI_EN
*ECCTL2 = 1 << 7; // Disable sync out bit 7 bit.SYNCO_SEL
*ECCTL2 = 1 << 6; // Disable sync out bit 6 bit.SYNCO_SEL.
*ECCTL2 = 0 << 10; // Output is active high bit.APWMPOL
*ECEINT = 1 << 6; // Enable int @ CTR==PRD bit.CTR_EQ_PRD
*CAP1 = 0x00010000; // Load period register
*CAP2 = 0x00010000; // Load compare register
*ECCTL2 = 1 << 4; // Start the counter bit.TSCTRSTOP

}

void APWM_ISR()
{

Uint32 *ECCLR;

/* Clear the interrupt flag */

*ECCLR = 1 << 6; // Clear the interrupt flag bit.CTR_EQ_PRD
*ECCLR = 1 << 0; // Clear all INT interrupt flags bit.INT

refer following manual starting from page no: 243-282

http://www.ti.com/lit/ug/spruh91d/spruh91d.pdf