I have a HC908GP32 chip that I want to use to generate two PWM signal
to drive two motors, and also generate a pulse signal for a LED. The
two PWM signal can be generated by TIM output compare, but since there
is only 2 output pins for the TIM1 on the CP package, TIM2 cannot be
config directly to generate the pulse for LED.
Therefore I have config TIM2CH0 to "software compare", and in the
interrupt generated, I toggle a selected output pin (say PTA_PTA3) by
PTA_PTA3 =~ PTA_PTA3;
However, when I measure the output on PTA3, there is nothing.
The chip is driven by an external 9.8304MHZ crystal. The PLL is disabled.
So to test my concept is really working, I have enabled TIM1CH0 and TIM1CH1's channel interrupt, and in the ISR I have the same code as above on different pins, i.e.,
PTE_PTE0 =~ PTE_PTE0;
I then go and measured the output. I have discovered that TIM1CH0's interrupt toggles PTE_PTE0 every 11.8us (but the channel overflow period is 1.3ms, channel compare is 50% of the channel mod). Further more, TIM1CH1's interrupt seems to be not working, there is nothing measured on PTE_PTE1, and nothing on PTA_PTA3 either.
This leads me to believe the timer is acting funny, so I measured the actual channel output pin on PTD_PTD5/6, their period is 1.3ms exactly. So the timer is differently generating PWM signal fine, it's just that the interrupts are weird.
So I'm really confused by the result. Can someone explain to me why this is happening. How the TIM module interrupt work, and what is the interrupt frequency? Can I generate 2 actively monitored PWM signals and one fixed frequency/duty cycle pulse signal on this particular MCU?