I am using the code below to set up timer0 to create a PWM output with a fixed period and from time to time I change the width.
*pTM0CTL = 0; // Clear any old settings
*pTM0CTL = (TIMODEPWM | PULSE | PRDCNT ); // Set PWM mode, High output, Count to end of period
*pTM0CNT = 0x01;
*pTM0PRD = PWM_Freq; // Set to 40kHz
*pTM0W = PWM_VCXO; // Set default to 50% Duty
*pTM0STAT = (TIM0EN);
There are no interrupts enabled for timer0 and it simply auto reloads at the end of each period count.
When no other interrupts are enabled I get a very nice PWM output and can vary the width from 0-100% with no measurable jitter.
When other interrupts are enabled I'm getting up to 1us jitter on the period.
I'm creating approximately 40kHz PWM so 1us represents a large % of the period.
Since this is a free-running hardware timer with no interrupts required to reload it why is there jitter when other interrupts are enabled.
I can understand interrupt latency causing jitter if software had to handle the interrupts for timer0 but there is none for this timer and it's supposed to be hardware based...
Is there some latency in the hardware reload that is interrupt dependant?
Is there another way to configure the timer to produce PWM jitter-free (well, low jitter within the spec of the device)?
I can't use the PWM outputs because this chip does have them or the ability to map to the DPI...
Thanks in advance.