I'm trying to create a periodic signal using 2 timers since the pin I need is not connected as a CCP. One timer is periodic at 400 us, and the other timer waits to be triggered before counting up 10 us. The pin goes high on the 400us timer interrupt, and goes low after 10us on the other timer's interrupt.
The problem is that the high time of the signal will be 10us most of the time, but will vary ~ +/- 4us every once in a while. (According to the oscilloscope) It does not always stay at 10 us. What could be the reason for this happening?
I have attached the project for easy testing, and posted a snippet of the code below:
TimerConfigure(TIMER4_BASE, TIMER_CFG_SPLIT_PAIR | TIMER_CFG_A_PERIODIC_UP | TIMER_CFG_B_ONE_SHOT_UP); TimerLoadSet(TIMER4_BASE, TIMER_A, (BOARD_CLOCK / TIM5_FREQ) - 1); TimerIntDisable(TIMER4_BASE, TIMER_TIMA_TIMEOUT); TimerIntClear(TIMER4_BASE, TIMER_TIMA_TIMEOUT); TimerIntEnable(TIMER4_BASE, TIMER_TIMA_TIMEOUT); TimerLoadSet(TIMER4_BASE, TIMER_B, TIM5B_10US); TimerIntDisable(TIMER4_BASE, TIMER_TIMB_TIMEOUT); TimerIntClear(TIMER4_BASE, TIMER_TIMB_TIMEOUT); TimerIntEnable(TIMER4_BASE, TIMER_TIMB_TIMEOUT); TimerControlWaitOnTrigger(TIMER4_BASE, TIMER_B, true); TimerEnable(TIMER4_BASE, TIMER_A); TimerEnable(TIMER4_BASE, TIMER_B); void Timer5A_HWI_Fxn(UArg arg) { HWREG(0x40061040) = 0x10; // K4 // Clear Interrupt TimerIntClear(TIMER4_BASE, TIMER_TIMA_TIMEOUT); } void Timer5B_HWI_Fxn(UArg arg) { HWREG(0x40061040) = 0; // K4 // Clear Interrupt TimerIntClear(TIMER4_BASE, TIMER_TIMB_TIMEOUT); TimerEnable(TIMER4_BASE, TIMER_B); }