drivers: pwm: pwm_mchp_xec: Fix u32_t overflow for freq calculation

Fixes u32_t overflow during intermediary calculations using u64_t for
it. on_off is temporary value used for calculating on and off and it
got overflowed with simple test in tests/drivers/pwm/pwm_api
([period]: 2000, [pulse]: 2000)

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2019-09-27 11:04:12 +03:00 committed by Anas Nashif
parent 0a85239d0d
commit 288940dbbd
1 changed files with 1 additions and 1 deletions

View File

@ -124,7 +124,7 @@ static u16_t xec_select_div(u32_t freq, u32_t max_freq[16])
static void xec_compute_on_off(u32_t freq, u32_t dc, u32_t clk,
u32_t *on, u32_t *off)
{
u32_t on_off;
u64_t on_off;
on_off = (clk * 10) / freq;