drivers: pwm: Fix wrong dc calculation for pwm tests
Values used in tests/drivers/pwm/pwm_api overflows calculation inside xec_compute_dc(). Make calculation to be done in u64_t and then convert to int. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
ff733369ec
commit
14c200d022
1 changed files with 2 additions and 1 deletions
|
@ -136,7 +136,8 @@ static u32_t xec_compute_dc(u32_t on, u32_t off)
|
||||||
{
|
{
|
||||||
int dc = (on + 1) + (off + 1);
|
int dc = (on + 1) + (off + 1);
|
||||||
|
|
||||||
dc = (((on + 1) * XEC_PWM_DC_PF) / dc);
|
/* Make calculation in u64_t since XEC_PWM_DC_PF is large */
|
||||||
|
dc = (((u64_t)(on + 1) * XEC_PWM_DC_PF) / dc);
|
||||||
|
|
||||||
return (u32_t)dc;
|
return (u32_t)dc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue