summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMulin Chao <mlchao@nuvoton.com>2016-08-12 11:34:15 +0800
committerchrome-bot <chrome-bot@chromium.org>2016-08-12 20:49:49 -0700
commite0497b041ac077673ffa182a3cb0e39f7c0c0cf6 (patch)
treed96bd448d9dbb82f48b7af3e94330b28dec8c16f
parent31f297da0b9cb3b4e6fb1cc2f044f71df1c830c2 (diff)
downloadchrome-ec-e0497b041ac077673ffa182a3cb0e39f7c0c0cf6.tar.gz
npcx: Fixed pwm bug to improve deviation of PWM frequency.
According the formula for computing prescaler of PWM, we needn't minus one again in line 89 of pwm.c. On npcx's evb, we observe the deviation of PWM 1 which freq is 10K is reduced from 0.6 kHz to 0.01 kHz. We also change PWM 1's freq to 100 Hz with PWM_CONFIG_DSLEEP and the deviation is reduced from 64.2 Hz to 9.2Hz. Modified sources: 1. pwm.c: Modifed formula for computing prescaler of PWM. BRANCH=none BUG=chrome-os-partner:56052 TEST=make BOARD=npcx_evb; use "pwm 1 50" to observe deviation of freq Change-Id: I9cd7fc0d807df62083d49a7e9ec6de1d9028be1b Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/368560 Reviewed-by: Shawn N <shawnn@chromium.org>
-rw-r--r--chip/npcx/pwm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/chip/npcx/pwm.c b/chip/npcx/pwm.c
index 32f676aa27..0f30e3cad4 100644
--- a/chip/npcx/pwm.c
+++ b/chip/npcx/pwm.c
@@ -86,7 +86,7 @@ void pwm_set_freq(enum pwm_channel ch, uint32_t freq, uint32_t res)
prescaler_divider = 0xFFFF;
/* Configure computed prescaler and resolution */
- NPCX_PRSC(mdl) = (uint16_t)prescaler_divider - 1;
+ NPCX_PRSC(mdl) = (uint16_t)prescaler_divider;
/* Set PWM cycle time */
NPCX_CTR(mdl) = res - 1;