Skip to content
Snippets Groups Projects
Commit c41d7ebd authored by David Sidrane's avatar David Sidrane Committed by Lorenz Meier
Browse files

kinetis:Bug fix PWM led update

  The code was forcing the CV reload, but not resettting the count
  this would cause short and long blinks during breathing.

  this change allows the CV to update at 50Hz (20 ms) asynchronously.
  So the LED update rate of 40Hz (25) will take effect on the next
  FTM counter change, end of the prescaler counting, after CnV register
  was written.update.
                   a   b   c   d
  LED PWM   ___-___-___-___-___-___-___-___-___-___
  LED Data  ____-____-____-____-____-____-____-____-
                 a    b    c    d
parent 16a23c55
No related branches found
No related tags found
No related merge requests found
......@@ -203,10 +203,10 @@ led_pwm_timer_init(unsigned timer)
/*
* Note we do the Standard PWM Out init here
* default to updating at 50Hz
* default to updating at LED_PWM_RATE
*/
led_pwm_timer_set_rate(timer, 50);
led_pwm_timer_set_rate(timer, LED_PWM_RATE);
}
}
unsigned
......@@ -274,12 +274,7 @@ led_pwm_servo_set(unsigned channel, uint8_t cvalue)
value--;
}
irqstate_t flags = px4_enter_critical_section();
uint32_t save = rSC(timer);
rSC(timer) = save & ~(FTM_SC_CLKS_MASK);
REG(timer, KINETIS_FTM_CV_OFFSET(led_pwm_channels[channel].timer_channel - 1)) = value;
rSC(timer) = save;
px4_leave_critical_section(flags);
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment