for(int i = 0; i <= PWM_HW_MAX_PRESCALER_STEP; i++)
{
period = CPU_FREQ / (BV(i) * freq);
-// LOG_INFO("period[%ld], prescale[%d]\n", period, i);
+ LOG_INFO("period[%ld], prescale[%d]\n", period, i);
if ((period < PWM_HW_MAX_PERIOD) && (period != 0))
{
//Clean previous channel prescaler, and set new
*/
if (!duty)
{
- PWM_PIO_PER = pwm_map[dev].pwm_pin;
+ PWM_PIO_CODR = pwm_map[dev].pwm_pin;
+ PWM_PIO_PER = pwm_map[dev].pwm_pin;
pwm_map[dev].duty_zero = true;
}
else
{
- /*
+ /*
* If polarity flag is true we must invert
* PWM polarity.
*/
}
PWM_PIO_PDR = pwm_map[dev].pwm_pin;
+ PWM_PIO_ABSR = pwm_map[dev].pwm_pin;
+
*pwm_map[dev].update_reg = duty;
pwm_map[dev].duty_zero = false;
}
PWM_ENA = BV(dev);
-
LOG_INFO("PWM ch[%d] duty[%d], period[%ld]\n", dev, duty, *pwm_map[dev].period_reg);
}
void pwm_hw_enable(PwmDev dev)
{
if (!pwm_map[dev].duty_zero)
- PWM_PIO_PDR = pwm_map[dev].pwm_pin;
+ {
+ PWM_PIO_PDR = pwm_map[dev].pwm_pin;
+ PWM_PIO_ABSR = pwm_map[dev].pwm_pin;
+ }
}
/**
* - Power on PWM
*/
PWM_PIO_CODR = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3);
- PWM_PIO_OER = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3);
- PWM_PIO_PDR = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3);
+ PWM_PIO_OER = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3);
+ PWM_PIO_PDR = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3);
PWM_PIO_ABSR = BV(PWM0) | BV(PWM1) | BV(PWM2) | BV(PWM3);
PMC_PCER |= BV(PWMC_ID);