AnsweredAssumed Answered

ADuCM360 PWM implementation

Question asked by Absel on Dec 13, 2017
Latest reply on Mar 12, 2018 by barryzhang

Hello. I'm trying to implement a PWM that modifies its duty cycle depending on the ADC measures. I have configured the ADC at maximum conversion rate (around 4kHz).

 

In the first place, I have a question. Is there any way to change the duty cycle of the PWM apart from using the function PwmGo to Disable, then reconfigure the PWM with PwmTime and then using PwmGo to Enable again? I'm actually using this in the interrupt of the PWM and I'm experiencing some noise peaks every period (1 ms). See picture below:

EDIT: I've seen that with PWMCON0 third bit set to 1 I don't need to enable/disable the PWM.

 

 

I have a question:

 

Is there a way to configure the duty cycle to be 0%? If I edit the PwmTime with 0 I get a lot of noise in a signal that should

be flat.

 

You will also find attached the project I'm working on.

 

On the other hand, if you take a look at my code you will see that I'm using the AdcRd function inside the interrupt of the PWM. Is it wrong? I'm doing this in order to have a proper timing, as I will read the Adc register every period, in a synchronous way.

Is it better to do it implementing a Timer? If that's the case, would you give me a fast example on how to synchronize the ADC readings in the ADC interrupt with the PWM? I've been fighting to get it but I cannot make it work.

 

Any ideas on how to implement this would be awesome. I'm just trying to change the PWM duty cycle depending on the ADC readings. (PWM period = 1 ms, ADC conversion rate = 1 conversion every 256 usec).

 

Thanks in advance,

 

Regards.

Attachments

Outcomes