AnsweredAssumed Answered

HCS12x Enhanced capture timer

Question asked by huck lim on Feb 6, 2014
Latest reply on Feb 7, 2014 by huck lim

Hello,

I have a question regarding the Enhanced capture timer. I am using the ECT as interrupt timer. I set the TC1 to fire the interrupt at a specific compare output. The sequence of the instruction is as below:

 

ECT_TCNT = 0;

asm BSET ECT_TSCR1, #0x80 //timer started

ECT_TC1 = ECT_TCNT + 6400;

asm BSET ECT_TIE, #0x02 //interrupt enable

 

Presumably the interrupt will fire when the timer counted from 0 to 6400. What I noticed is that the first interrupt was triggered right away, which is not what I expected. Thereafter the interrupt triggered at regular interval, which is what I expected.

 

If I change the ECT_TCNT's initial value, for example,

ECT_TCNT = 10000;  //---------changed this initial value

asm BSET ECT_TSCR1, #0x80 //timer started

ECT_TC1 = ECT_TCNT + 6400;

asm BSET ECT_TIE, #0x02 //interrupt enable

 

Then everything works fine. The first interrupt was not triggered right away.

 

Can anybody explain to me why the initial value of ECT_TCNT makes the difference? I think I read about this in the manual somewhere, but I cannot find it anymore.

 

Yours sincerely,

Huck

Outcomes