Hi folks,
I am trying to setup an F28027 PWM (2A) that uses a sync input (from TZ1). I have code that outputs a PWM signal only as long as TBCTL.PHSEN is 0.
When I try to run the same code with the counter load enabled and use a software force on the sync to start the PWM, the GPIO pin is always LOW.
The below code works fine without the PWM_enableCounterLoad() line, but as soon as I uncomment it again, there is no PWM output... what am I doing wrong please?
Thanks!
CLK_enablePwmClock(clk, PWM_Number_2); /* Enable clock to PWM2. */ GPIO_setDirection(gpioHandle, pwmGpioNumber, GPIO_Direction_Output); /* Configure GPIO as PWM output. */ GPIO_setPullUp(gpioHandle, pwmGpioNumber, GPIO_PullUp_Enable); GPIO_setLow(gpioHandle, pwmGpioNumber); GPIO_setMode(gpioHandle, pwmGpioNumber, GPIO_0_Mode_EPWM1A); /* Time base submodule. */ PWM_setPeriodLoad(pwmHandle, PWM_PeriodLoad_Immediate); /* Set immediate load. */ PWM_setPeriod(pwmHandle, myperiod - 1U); /* Frequency = 1 / period. */ PWM_setPhase(pwmHandle, 0U); /* Set phase to 0 degreees. */ PWM_setCount(pwmHandle, 0U); /* Zero the count. */ PWM_setCounterMode(pwmHandle, PWM_CounterMode_Up); /* Set counter to count-up mode. */ PWM_setHighSpeedClkDiv(pwmHandle, PWM_HspClkDiv_by_1); /* TBCLK = SYSCLKOUT / 1. */ PWM_setClkDiv(pwmHandle, PWM_ClkDiv_by_1); // PWM_enableCounterLoad(pwmHandle); /* Enable load counter from phase register when sync'd. */ PWM_setSyncMode(pwmHandle, PWM_SyncMode_EPWMxSYNC); /* Enable synchonization input. */ /* Counter compare submodule. */ PWM_setCmpA(pwmHandle, CALC_IMIN_DUTY_PERIOD(ishr->period));/* Set output A duty to I_min initially. */ PWM_setCmpB(pwmHandle, 0); /* Clear output B duty (unused). */ PWM_setShadowMode_CmpA(pwmHandle, PWM_ShadowMode_Shadow); /* Load compare from the shadow register. */ PWM_setLoadMode_CmpA(pwmHandle, PWM_LoadMode_Period); /* Load compare at end of period. */ /* Action qualifier submodule. */ PWM_setActionQual_Zero_PwmA(pwmHandle, PWM_ActionQual_Set); /* Set output A HIGH at start of period. */ PWM_setActionQual_CntUp_CmpA_PwmA(pwmHandle, PWM_ActionQual_Clear); /* Set output A LOW at counter compare A value. */ PWM_setActionQual_Zero_PwmB(pwmHandle, PWM_ActionQual_Disabled); /* Disable any action on output B (unused). */ PWM_setActionQual_CntUp_CmpA_PwmB(pwmHandle, PWM_ActionQual_Disabled); PWM_setActionQual_Period_PwmB(pwmHandle, PWM_ActionQual_Disabled); PWM_forceSync(pwmHandle); /* Force the PWM sync to start the PWM output. */
CLK_enableTbClockSync(clkHandle);/