Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 217585

Forum Post: CCS/MSP-EXP432P4111: Updating PWM Duty Cycle Live - DriverLib

$
0
0
Part Number: MSP-EXP432P4111 Tool/software: Code Composer Studio Hello, I am using the lines of code below to update my PWM duty cycle based on the results of the ADC. Basically, I am setting a desired output current and reading the actually current through the ADC. Based on the difference I increase or decrease my PWM duty cycle proportional to the error. Is there a way to update the PWM duty cycle rather than re-generating it? Note that I am using DriverLib. This re-generation is affecting my output ripple current drastically. if(SetPoint - offsetlow > curADCResult){ e = SetPoint - curADCResult; u = kp*e; if(u > PWMSteps){ u = PWMSteps; }if(u PWMSteps){ u = PWMSteps; }if(u < 0){ u = 0; } if ((uint16_t)u < 1){ pwmConfig.dutyCycle -= 1; Timer_A_generatePWM(TIMER_A2_BASE, &pwmConfig); } else{ pwmConfig.dutyCycle -= (uint16_t)u; Timer_A_generatePWM(TIMER_A2_BASE, &pwmConfig); } } if(SetPoint == 0){ pwmConfig.dutyCycle = 350; Timer_A_generatePWM(TIMER_A2_BASE, &pwmConfig); } Please advise. Grant Griffin

Viewing all articles
Browse latest Browse all 217585

Trending Articles