This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
I'm having a little trouble envisioning how you're expecting the waveform to behave. I would think you would want to scale your CMPA value based on what the TBPRD value is. Since the original program you started with used a TBPRD equal to the maximum value that the ADC was going to return, there was no need to scale it. Now that you're varying the frequency though, it becomes important. CMPA= ((adcresult * TBPRD) / 4096) or something along those lines, right?
If you do want to try changing the HSPCLKDIV and CLKDIV like you mentioned, you use PWM_setHighSpeedClkDiv() and PWM_setClkDiv() respectively. It looks like right now you're dividing the clock by 10.
Whitney
So since you say it's "running correctly," does that mean your issue is solved or do you still need help?
Thanks,
Whitney