Hello
I'm using the TM4C1294xl to control three stepper motors. As usual a PWM signal is needed to make a moving step. For accerlation / deaccerlation it is necessary to increase / decrease the frequency.
I have written down following code for testing.
int main(void){ //activate ports SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOK); //switch to PWM mode GPIOPinConfigure(GPIO_PF1_M0PWM1); GPIOPinConfigure(GPIO_PG1_M0PWM5); GPIOPinConfigure(GPIO_PK4_M0PWM6); GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_1); GPIOPinTypePWM(GPIO_PORTK_BASE, GPIO_PIN_4); //switch on generator SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); //PortF (generator0) PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); //PortG (generato2) PWMGenConfigure(PWM0_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); //PortK (generator3) //set specefic pulsewidth / frequency PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, 100); //PortF PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, 50); PWMGenEnable(PWM0_BASE, PWM_GEN_0); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, 400); //PortG PWMPulseWidthSet(PWM0_BASE, PWM_OUT_5, 300); PWMGenEnable(PWM0_BASE, PWM_GEN_2); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_3, 400); //PortK PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6, 100); PWMGenEnable(PWM0_BASE, PWM_GEN_3); PWMOutputState(PWM0_BASE, PWM_OUT_1_BIT | PWM_OUT_5_BIT | PWM_OUT_6_BIT , true); }
My question in now: Is it possible to change the frequency and duty of each signal on the fly? I've already tried out using a for loop with the single commands inserted like
for(i=1;i<400;i++){ PWMGenPeriodSet(PWM0_BASE, PWM_GEN_3, i); }
but no success. The only thing that is measurable is that the PWM output becomes dodgy. It simpy switches on and off providing a PWM signal in between.
Does anyone knows better / has an advice?
Thanks for your responce!
Greetings