Hello everyone.
I know there are already some threads about timer sync, but I´ve tried all the suggested steps mentioned and i´m still not able to sync the timers i´m using.
I´m quite a noob on these matters, so please bear it with me.
A CCD project i´m working on requires quite some timers to obtain an image.
What i´m trying to do is to run, for now, 3 different timers.
My original configuration was:
Timer0 -> split pair, TimerA-pwm, with an interrupt
Timer1 -> split pair, TimerA-pwm, TimerB-oneShot with prescaler and an interrupt
Timer2->split pair, TimerA-pwm
I had no sucess trying to sync Timer2_A with Timer1_A which is my final goal.
Later I learned that Timer0 must be used to sync other timers so i´ve changed the configuration so that Timer0 was there only to sync.
I´ve been changing the configuration of all the timers and trying different combinations but with no sucess.
Now all I want is to sync Timer1 and Timer2, both running simple PWM in their A half with output in the respective pins and both with the same frequency and dutyCycle.
By sync i mean that their waveform should start at the same time so that later on i can change the dutyCycle in order to create a shift on the wave.
Here is an piece of my code for the timers:
//act timers Peripherals
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
//
TimerSynchronize(TIMER0_BASE, TIMER_1A_SYNC | TIMER_2A_SYNC );
TimerSynchronize(TIMER0_BASE,0);
//********************
//act timers outputs
GPIOPinConfigure(GPIO_PB4_T1CCP0);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_4);//timer1
GPIOPinConfigure(GPIO_PB0_T2CCP0);
GPIOPinTypeTimer(GPIO_PORTB_BASE, GPIO_PIN_0);//timer2
//********************
//type of timers config
TimerConfigure(TIMER1_BASE, TIMER_CFG_SPLIT_PAIR| TIMER_CFG_A_PWM);
TimerConfigure(TIMER2_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM);
//********************
//Timers_time config
TimerLoadSet(TIMER1_BASE, TIMER_A, 100 -1);
TimerMatchSet(TIMER1_BASE, TIMER_A, 50 );
TimerLoadSet(TIMER2_BASE, TIMER_A, 100 -1);
TimerMatchSet(TIMER2_BASE, TIMER_A, 50);
//********************
//********************
//act timers
TimerEnable(TIMER1_BASE, TIMER_A);
TimerEnable(TIMER2_BASE, TIMER_A);
Can anyone explain me what am i doing wrong?
Any suggestion are appreciated.
Thanks for your time. (pun intended)