Part Number: TM4C129ENCPDT
I'm using Timer5A in PWM mode to produce a signal that is high at all times, except a periodic 100ns low-going pulse every 833us. It works correctly, but not at the beginning.
Code:
// Output pulse on T5CCP0, PB2, using Timer5A
// Configure half timer as PWM (0x0400000A)
MAP_TimerConfigure(TIMER5_BASE, TIMER_A, TIMER_CFG_A_PWM | TIMER_CFG_SPLIT_PAIR);
// Configure waveform to pause when CPU halts in debugger
MAP_TimerControlStall(TIMER5_BASE, TIMER_A, true);
// Configure output level as normal (not inverted)
MAP_TimerControlLevel(TIMER5_BASE, TIMER_A, false);
// Configure to trigger interrupt on rising edge
MAP_TimerControlEvent(TIMER5_BASE, TIMER_A, TIMER_EVENT_POS_EDGE);
// Set PWM period: Put high byte in prescaler register, low word in interval load register
MAP_TimerPrescaleSet(TIMER5_BASE, TIMER_A, (100000 >> 16) & 0xff);
MAP_TimerLoadSet(TIMER5_BASE, TIMER_A, 100000 & 0xffff);
// Set PWM duty: Put high byte in prescale match register, low word in match register
MAP_TimerPrescaleMatchSet(TIMER5_BASE, TIMER_A, (100 >> 16) & 0xff);
MAP_TimerMatchSet(TIMER5_BASE, TIMER_A, 100 & 0xffff);
Lots of other things happen; much time passes, and then:
// Enable timer
MAP_TimerEnable(TIMER5_BASE, TIMER_A);
This output signal has a pull-up. Therefore, at power-up, with the pin at high impedance, the signal is high as desired.
The problem is that when MAP_TimerConfigure() executes, the output goes low and remains low. Later, when MAP_TimerEnable() executes, the output remains low until the first 833us period elapses + the 100ns low pulse. Then it finally transitions to high and operates as desired from that moment on.
I need to eliminate that long period of low output because this signal triggers other hardware and I need to avoid unwanted transitions.
It occurred to me that I should leave the pin as a GPIO and drive it high, until after the call to MAP_TimerEnable().
But this will not work because as soon as the pad is configured for alternate function (timer), the signal will go low, giving the unwanted transition, until the timer runs through the first period.
Is there anything I could do to the timer that will avoid this first time phenomenon?