Mohamed Othman

HCS12 PWM

Discussion created by Mohamed Othman on Jan 30, 2008
Latest reply on Feb 1, 2008 by Brett Wallace
Hello,
I am using the PWM. the problem is that sometimes I get a capacitive (charging/discharging) effects on the edges of the PWM signal.
 
Can anyone please help me in that?
what would be the reason from not having a regular PWM signal generated from the PWM module?
thanks.
here is the code.
void PWM1_16bit_freq(float freq,float duty)
 {
  unsigned int total;
  int_val x,y;
  if (!((freq==0.0f)||(duty==0.0f)))
  {
  PWME.b.b1=1;// disable the channel  
  total=24000/freq;
  x.val=total;
  PWMPER0.byte=x.byteval[0];
  PWMPER1.byte=x.byteval[1];
  y.val=(total * duty)/100;
  PWMDTY0.byte=y.byteval[0];
  PWMDTY1.byte=y.byteval[1];
    }
   else
   {
  PWMPER0.byte=0;
  PWMPER1.byte=0;
  PWMDTY0.byte=0;
  PWMDTY1.byte=0;
  PWME.b.b1=0;
 
   }
 }

Outcomes