Stefan Mardale

PWM prescale

Discussion created by Stefan Mardale on Mar 14, 2008
Latest reply on Mar 15, 2008 by Stefan Mardale
    hello, I'm using an MCS12C32 and I want to generate a 60Hz PWM signal. On paper every thing is ok, but not in the real world. I'm using a LED to test, and it blinks every 4-5 sec. Can anyobody help me? The qurtz works at 16Mhz, this means a 8Mhz bus clock(right?).


SA=BUS clk/2*PSCLA     
BUS clk=8Mhz/128=62.5Khz
SA=62.5Khz/2*512=61Hz

here is the init():

void init_pwm(void)
{




 PWMPOL_PPOL0=1; //start pol
 PWMPOL_PPOL1=1;
 PWMPOL_PPOL2=1;
 PWMPOL_PPOL3=1;
 
 
 
 PWMCLK_PCLK0=1;//ch1- SA
 PWMCLK_PCLK1=1;
 PWMCLK_PCLK2=1;
 PWMCLK_PCLK3=1;
 
 
 PWMPRCLK_PCKA0=1;//prescale bus clk  with 128     8Mhz/128=62.5Khz
 PWMPRCLK_PCKA1=1;
 PWMPRCLK_PCKA2=1;
 
 PWMPRCLK_PCKB0=1;
 PWMPRCLK_PCKB1=1;
 PWMPRCLK_PCKB2=1;
 
 PWMSCLA=0xFFFF;  //prescale SA with 512
 PWMSCLB=0xFFFF;                  

 PWMPER0=255;//perioada
 PWMPER1=255;
 PWMPER2=255;
 PWMPER3=255;

 
}

Outcomes