AnsweredAssumed Answered

About  the  ECT  of  mc9s12xep100

Question asked by youdong sheng on Jul 4, 2017
Latest reply on Jul 4, 2017 by Daniel Martynek

I want to measure the duty cycle of PWM,  use the ECT function of mc9s12xep100, The fllowing is my code :

 

void ECT_Init(void)
{
ECT_TSCR2 = 0x80; // prescaller=1
ECT_TCTL3 = 0x04; // channel 5 input capture on rising edge
ECT_TIE = 0x20; // enable Ch5 interrupt
ECT_TSCR1 = 0xE0; // enable timer, stop during freeze and wait
}

 

#pragma CODE_SEG NON_BANKED
void interrupt 13 ECT4_ISR(void)
{
unsigned int ovfs;

TIM_TFLG1 = 0x20; // clear interrupt flag from PT5

}
#pragma CODE_SEG DEFAULT


#pragma CODE_SEG NON_BANKED
interrupt 16 void TIM_OvfIsr(void)
{
ch4ovfCnt++; // count overflows
ch5ovfCnt++;
ch6ovfCnt++;
ch7ovfCnt++;

TIM_TFLG2 = 0x80; // clear interrupt flag of main timer
}
#pragma CODE_SEG DEFAULT

 

 

I found that the flags of interupt can't be cleared causing the interrupt is always running.

 

Does my code  have any problem?

 

how can I clear the flag of interrupt? 

Outcomes