Joao Freitas

Problem with MC9S12NE64V1's timer!!

Discussion created by Joao Freitas on Dec 12, 2007
Latest reply on Dec 14, 2007 by Joao Freitas
    Hello,

I´m using the MC9S12NE64V1 and I'm having some problems when debugging in CodeWarrior IDE version 5.7.0. I'm trying to program the Timer to generate interrupts. But the problem occurs when I debug the program. I can´t clear the interrupt flag of Timer and the program is always going to the interruption part, even when I disable the Timer. The code to configure the Timer is present below:

    TIOS_IOS4 = 1;   // timer 4 output compare
    TSCR2_PR = 0;    // prescaler 0 : 25Mhz
    TIE_C4I = 0;     // interrupt 4 enable
    TSCR1_TSFRZ = 1; // disable timer in freeze mode

    TC4 = _TCNT.Word + 200;
    TSCR1_TEN = 1;   // enable timer

Another doubt, the TFLG1_C4F flag is set when I enable the Timer, why this happen? I clear the flag with the command in the end of interruption:
   
    TFLG1_C4F = 1;

But the flag doesn't clear. For debugging the code, I'm using the Serial Monitor.

Thanks,

João Paulo.




Outcomes