Beispiel #1
0
unsigned char PWM_DutyCycle(int channel, int freq) 
{ 
    uint32  pwmlen;
    uint16  pwmh_high;

#if 0
    //uiPWMH_High: mul*10  
    if (uiPWMH_High > 1000) 
        return 1;       // Error 
#else 
    if (uiPWMH_High > freq){
        uiPWMH_High             = freq;
    }
#endif
    //Note that
    //鈥� Except for LCOMP, all other bits of PWMCON0 register can be changed
    //only when PWMEN is low.
    //鈥� When LCOMP is written with Value 1, it stays at that value until
    //the new value is loaded in the compare registers for all the channels.
    pwm_output_disable(); 
#if 0
    pwmlen  = static_cast<uint32>(8000000)/freq - 1;
    pwmh_high       = (uint16)((pwmlen*uiPWMH_High)/1000);
#else 
    pwmlen      = freq;
    pwmh_high   = uiPWMH_High;
#endif
    PwmTime(iPair, pwmlen, pwmh_high, 0);
    PwmLoad(PWMCON0_LCOMP_EN);
    pwm_output_enable(); 
    
    return 0;
} 
Beispiel #2
0
void pwm_config(void)
{
    pwm_output_disable();
    Periodo_ticks = pwm_period_calculation(F_SAMP);
    pwm1_config();  //pulsos disparo
    pwm2_config();  //pulsos disparo
    pwm3_config();  
    pwm4_config();  //DAC pwm
    pwm5_config();  //Gera sinal CNVST para iniciar conversao do AD7634
    InitEPwm1Gpio();
    InitEPwm2Gpio();
    InitEPwm3Gpio();
    InitEPwm4Gpio();
    InitEPwm5Gpio();
    
    pwm_mep_sfo_init();
}
Beispiel #3
0
unsigned char PWM_Freq(int channel, uint16 freq)
{
    int iPair;
    uint16 duty_cycle;
    uint16 old_freq;
    
    PWM_ParamGet(channel, &old_freq, &duty_cycle, &iPair);
    if (freq != old_freq){
        if (duty_cycle > freq){
            duty_cycle                  = freq;
        }
        pwm_output_disable(); 
        PwmTime(iPair, freq, duty_cycle, 1);
        pwm_output_enable();
    }
    
    return 0;
}
Beispiel #4
0
void drive_halt(void)
{
    pwm_output_disable();
    sine_reset();
}