Hello everyone,
I'm working with the EK-TM4C1294XL Launchpad and trying to figure out how to generate only one Puls with the PWM-Module.
My idea was to start the Timer an when it reaches Zero to trigger an Interrupt and in the Interrupt to disable the Timer but it doesn't work.
I hope someone can help me.
Best regards
#include "../src/pwm_gpio_driver.h"
volatile int i=0;
void pwm_gpio_config(void){
SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinConfigure(GPIO_PF1_M0PWM1); /* PF1 */
GPIOPinTypePWM(GPIO_PORTF_BASE , GPIO_PIN_1); /* PF1 */
IntRegister(INT_PWM0_0, PWM0_PF1_Handler); /* PF1 */
IntEnable(INT_PWM0_0); /* PF1 */
IntMasterEnable();
PWMIntEnable(PWM0_BASE, PWM_INT_GEN_0); /* PF1 */
PWMGenIntTrigEnable(PWM0_BASE, PWM_GEN_0, PWM_INT_CNT_ZERO ); /* PF1 */
PWMGenConfigure(PWM0_BASE,PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); /* PF1 */
PWMGenPeriodSet(PWM0_BASE,PWM_GEN_0, Frequency); /* PF1 */
PWMPulseWidthSet(PWM0_BASE,PWM_OUT_1,(1600*Duty_Cycle)); /* PF1 */
PWMGenEnable(PWM0_BASE, PWM_GEN_0); /* PF1 */
PWMOutputState(PWM0_BASE, (PWM_OUT_1_BIT), true);
}
void PWM0_PF1_Handler(void)
{
/* Clears the specified interrupt for the specified PWM generator block. */
PWMGenIntClear(PWM0_BASE, PWM_GEN_0, PWM_INT_CNT_ZERO);
PWMGenDisable(PWM0_BASE, PWM_GEN_0);
/* Disabling the PF1 PWM Output */
// PWMOutputState(PWM0_BASE, (PWM_OUT_1_BIT), false);
}