Skip to content

Commit

Permalink
Merge branch 'Sissors-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xc0170 committed Jul 23, 2014
2 parents 21ddd8b + f56f375 commit 6663575
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ void pwmout_write(pwmout_t* obj, float value) {
value = 1.0;
}

*obj->CnV = (uint32_t)((float)(*obj->MOD) * value);
*obj->CnV = (uint32_t)((float)(*obj->MOD + 1) * value);
}

float pwmout_read(pwmout_t* obj) {
float v = (float)(*obj->CnV) / (float)(*obj->MOD);
float v = (float)(*obj->CnV) / (float)(*obj->MOD + 1);
return (v > 1.0) ? (1.0) : (v);
}

Expand All @@ -118,7 +118,7 @@ void pwmout_period_ms(pwmout_t* obj, int ms) {
// Set the PWM period, keeping the duty cycle the same.
void pwmout_period_us(pwmout_t* obj, int us) {
float dc = pwmout_read(obj);
*obj->MOD = (uint32_t)(pwm_clock * (float)us);
*obj->MOD = (uint32_t)(pwm_clock * (float)us) - 1;
pwmout_write(obj, dc);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ void pwmout_write(pwmout_t* obj, float value) {
value = 1.0;
}

*obj->CnV = (uint32_t)((float)(*obj->MOD) * value);
*obj->CnV = (uint32_t)((float)(*obj->MOD + 1) * value);
*obj->CNT = 0;
}

float pwmout_read(pwmout_t* obj) {
float v = (float)(*obj->CnV) / (float)(*obj->MOD);
float v = (float)(*obj->CnV) / (float)(*obj->MOD + 1);
return (v > 1.0) ? (1.0) : (v);
}

Expand All @@ -98,7 +98,7 @@ void pwmout_period_ms(pwmout_t* obj, int ms) {
// Set the PWM period, keeping the duty cycle the same.
void pwmout_period_us(pwmout_t* obj, int us) {
float dc = pwmout_read(obj);
*obj->MOD = (uint32_t)(pwm_clock * (float)us);
*obj->MOD = (uint32_t)(pwm_clock * (float)us) - 1;
pwmout_write(obj, dc);
}

Expand Down

0 comments on commit 6663575

Please sign in to comment.