Tool/software: Code Composer Studio
Hello,
I am using the pwm as:
SysCtlPWMClockSet(SYSCTL_PWMDIV_8); ui32PWMClock = SysCtlClockGet() / 8; ui32Load = (ui32PWMClock / PWM_FREQUENCY) - 1; SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PB6_M0PWM0); GPIOPinConfigure(GPIO_PB7_M0PWM1); GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_6); GPIOPinTypePWM(GPIO_PORTB_BASE, GPIO_PIN_7); PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ui32Load); PWMGenEnable(PWM0_BASE, PWM_GEN_0); PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, true); // send zero pwm PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0 , 0); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1 , 0);
I can observe the waveform on both pins with a scope.
The problem is when I:
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, ui32Load);
I dont get a full pwm output, (a continuous 1) but I get a 0. PWM_FREQUENCY is 18000. if I make a
PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, ui32Load-1);
I get a nearly 99.9% pwm waveform
how can i work across this problem?
Edit:
To generate ui32Load, I have the following statements. I make sure that SysCtlClockGet is run after the tiva-c clock is set to 80mhz.
//#define PWM_FREQUENCY 18000 #define PWM_FREQUENCY 500 volatile uint32_t ui32Load; volatile uint32_t ui32PWMClock; -- SysCtlPWMClockSet(SYSCTL_PWMDIV_8); ui32PWMClock = SysCtlClockGet() / 8; ui32Load = (ui32PWMClock / PWM_FREQUENCY) - 1;
best regards,
c.