Hello everybody,
I've got a problem with PWM - it doesn't work when I enable timer interrupts.
I have just programmed the PWM on the channel 0, and I wanted to have an ISR to be called when output compare occurs on channel 1.
I have done the following steps:
1. Define an ISR function: it just resets the timer channel flag.
#pragma TRAP_PROC
void TIM_ISR(void)
{
TSC1; // read TIM channel status and control
TSC1_CH1F = 0; // clear timer channel flag
}
2. Add this ISR function to the interrupt vector:
void *const _vectab[] =
{
LIN_VECTF NULL, /* 0xFFDE ADC */
LIN_VECTF NULL, /* 0xFFE0 Keyboard */
LIN_VECTF NULL, /* 0xFFE2 Reserved */
LIN_VECTF NULL, /* 0xFFE4 Reserved */
LIN_VECTF NULL, /* 0xFFE6 Reserved */
LIN_VECTF NULL, /* 0xFFE8 Reserved */
LIN_VECTF SLIC_ISR, /* 0xFFEA SLIC */
LIN_VECTF NULL, /* 0xFFEC Reserved */
LIN_VECTF NULL, /* 0xFFEE Reserved */
LIN_VECTF NULL, /* 0xFFF0 Reserved */
LIN_VECTF NULL, /* 0xFFF2 TIMER overflow */
LIN_VECTF TIM_ISR, /* 0xFFF4 TIMER channel 1 */
LIN_VECTF NULL, /* 0xFFF6 TIMER channel 0 */
LIN_VECTF NULL, /* 0xFFF8 Reserved */
LIN_VECTF NULL, /* 0xFFFA IRQ */
LIN_VECTF NULL, /* 0xFFFC SWI */
LIN_VECTF _Startup /* 0xFFFE RESET */
};
3. Enable the interrupt in the main function:
TSC1_CH1IE = 1;
When the interrupt from channel 1 isn't enabled, the PWM based upon the channel 0 works correctly, but as soon as I enable this interrupt then the whole PWM stops working.
What do I wrong? Maybe should I do some additional things in ISR?
TIA,
Yac.