Other Parts Discussed in Thread: STRIKE
Hello,
i want to create three single shots as a gate signal for three mosfets. the duty cycle is variable and can be changed with a touch display.
i configured three timer in single shot mode and tested it.
but the one shots comes one after another and not at the same time (similar to the picture)
is it even possible to do three one shots at the same time? What i am doing wrong?
my code here:
/*
* Timer Config
*/
void timer_gpio_config(void){ //void timer_gpio_config(uint8_t *Slider_E_1){
/* Enable Timer */
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER3);
SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER2);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
/* Configure Timer A in single shot mode */
TimerConfigure(TIMER0_BASE, TIMER_CFG_A_ONE_SHOT); //TIMER_CFG_A_PERIODIC TIMER_CFG_A_ONE_SHOT
TimerConfigure(TIMER3_BASE, TIMER_CFG_A_ONE_SHOT);
TimerConfigure(TIMER2_BASE, TIMER_CFG_A_ONE_SHOT);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);
GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_0);
GPIOPinTypeGPIOOutput(GPIO_PORTL_BASE, GPIO_PIN_4);
GPIODirModeSet(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_DIR_MODE_OUT);
GPIODirModeSet(GPIO_PORTG_BASE, GPIO_PIN_0, GPIO_DIR_MODE_OUT);
GPIODirModeSet(GPIO_PORTL_BASE, GPIO_PIN_4, GPIO_DIR_MODE_OUT);
/* Registers a function to be called when an interrupt occurs P:355 */
IntRegister(INT_TIMER0A, timerIntHandler);
GPIOIntRegister(GPIO_PORTF_BASE, gpioIntHandler);
IntRegister(INT_TIMER3A, timerIntHandlerTimer1);
GPIOIntRegister(GPIO_PORTG_BASE, gpioIntHandler1);
IntRegister(INT_TIMER2A, timerIntHandlerTimer2);
GPIOIntRegister(GPIO_PORTL_BASE, gpioIntHandler2);
/* The specified interrupt is enabled */
IntEnable(INT_TIMER0A);
IntEnable(INT_TIMER3A);
IntEnable(INT_TIMER2A);
/* Enables the processor Interrupt */
IntMasterEnable();
/* Sets the Interrupt type for the specified pin */
GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_HIGH_LEVEL);
GPIOIntTypeSet(GPIO_PORTG_BASE, GPIO_PIN_0, GPIO_HIGH_LEVEL);
GPIOIntTypeSet(GPIO_PORTL_BASE, GPIO_PIN_4, GPIO_HIGH_LEVEL);
/* Enables the specified GPIO interrupts */
GPIOIntEnable(GPIO_PORTF_BASE, GPIO_INT_PIN_3);
GPIOIntEnable(GPIO_PORTG_BASE, GPIO_INT_PIN_0);
GPIOIntEnable(GPIO_PORTL_BASE, GPIO_INT_PIN_4);
/* Enables timer interrupt sources P: 543*/
TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
TimerIntEnable(TIMER3_BASE, TIMER_TIMA_TIMEOUT);
TimerIntEnable(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
}
void timer_start (){
TimerLoadSet(TIMER0_BASE, TIMER_A, 12000001 * Slider_E_1);
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_PIN_3);
TimerLoadSet(TIMER3_BASE, TIMER_A, 12000001 * Slider_E_2);
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_0, GPIO_PIN_0);
TimerLoadSet(TIMER2_BASE, TIMER_A, 12000001 * Slider_E_3);
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_4, GPIO_PIN_4);
}
void turbo_boost(void){
GPIOIntDisable(GPIO_PORTL_BASE, GPIO_INT_PIN_3);
GPIOIntDisable(GPIO_PORTL_BASE, GPIO_INT_PIN_4);
GPIOIntDisable(GPIO_PORTL_BASE, GPIO_INT_PIN_5);
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_3, GPIO_PIN_3);
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_4, GPIO_PIN_4);
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_5, GPIO_PIN_5);
TimerLoadSet(TIMER1_BASE, TIMER_A, 120001 * Slider_E_1);
}
void gpioIntHandler(void){
/* Enables the timer */
GPIOIntClear(GPIO_PORTF_BASE, GPIO_HIGH_LEVEL);
TimerEnable(TIMER0_BASE, TIMER_A);
}
void gpioIntHandler1(void){
/* Enables the timer */
GPIOIntClear(GPIO_PORTG_BASE, GPIO_HIGH_LEVEL);
TimerEnable(TIMER3_BASE, TIMER_A);
}
void gpioIntHandler2(void){
/* Enables the timer */
GPIOIntClear(GPIO_PORTL_BASE, GPIO_HIGH_LEVEL);
TimerEnable(TIMER2_BASE, TIMER_A);
}
void timerIntHandler (void){
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0);
/* Clears timer interrupt sources */
TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); /* Breakpoint hier setzen abi */
}
void timerIntHandlerTimer1 (void){
TimerIntClear(TIMER3_BASE, TIMER_TIMA_TIMEOUT);
GPIOPinWrite(GPIO_PORTG_BASE, GPIO_PIN_0, 0);
}
void timerIntHandlerTimer2 (void){
TimerIntClear(TIMER2_BASE, TIMER_TIMA_TIMEOUT);
GPIOPinWrite(GPIO_PORTL_BASE, GPIO_PIN_4, 0);
}