Tool/software: TI-RTOS
goodmorning,
Could you show me how to use PWM in PWM_DUTY_FRACTION mode. I tried but it seem not to work. thank you!
here is my config:
void pwm_demo(UArg arg0, UArg arg1)
{
//uint16_t pwmPeriod = 1000;
//uint16_t pwmfrequences = 1000; peirod in Hz
uint16_t duty = 0; // %
uint16_t dutyInc = 2.5; // %
PWM_Params_init(&pwmParams);
pwmParams.periodUnits = PWM_PERIOD_HZ;
pwmParams.periodValue = 1e3;
pwmParams.dutyUnits = PWM_DUTY_FRACTION;// mode fraction doesn't work, but PWM_DUTY_US mode has worked normally.
.pwmParams.dutyValue = 0;
pwmParams.idleLevel = PWM_IDLE_HIGH;
pwmHandle = PWM_open(Board_PWM1, &pwmParams);
if (pwmHandle == NULL) {
System_abort("Board_PWM1 did not open");
}
PWM_start(pwmHandle);
while (1) {
PWM_setDuty(pwmHandle, duty);
duty = duty + dutyInc; // increase the duty 2.5% each time
if (duty == 100 || duty == 0) {
dutyInc = - dutyInc;
}
Task_sleep(5000);
}
}