Cristal: 8Mhz
PLL: 48Mhz
PWM channel 2 configuration:
MODRR = 0x14; //port pin 2 and 4 was connected to pwm 2 and 4 output
PWME = 0; //PWM enable - disable initially
PWMPOL = 0x14; // pwm polarity
PWMCLK = 0x14; //clock select SA and SB selected
PWMPRCLK = 0x00; //bus prescaler select, using none
PWMSCLA = 0x0C; // pwm clock = SA clock/(2*PWMSCLA) = 24MHz/24 = 1 us clk
PWMSCLB = 0x0C; // pwm clock = SA clock/(2*PWMSCLA) = 24MHz/24 = 1 us clk
PWMCAE = 0x00; //pwm left aligned
PWMPER and PWMDTY was dynamically configured.
Timer 2 configuration:
TSCR2 = 0x84; //TIMER overflow interrupt enable and timer prescaler = 16, (time clock = (48MHz /2) / 16 = 0,666us)
TSCR1 = 0x80; //Timer enable
TIOS |= 0x04; //timer 2 channel is output compare
TIE |= 0x04; // timer 2 interrupt enable
TC2 = 0x01; // timer 2 output compare resgister, match every 1 count of timer (TCNT), TC2 was updated on code.
TCTL2 &= 0xCF; // timer control register, disconect timer 2 from output pin logic
TCTL4 &= 0xCF; // Capture disabled
TFLG1 |= 0x04; // Clear Timer2 flag (interrupt flag)
I´m trying configure to 0,666us, but the interrupt occur every 0,042ms. what I´m doing wrong?