diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2013-03-15 09:53:07 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-03-15 11:33:55 -0700 |
commit | 42d8a7b027e7a4313734e62caffedc852989a4db (patch) | |
tree | 61838b601bed5c650928da601193fa10da146414 | |
parent | 5dc8498fb690ed575c3d2132a5e9ee39aa5e235a (diff) | |
download | chrome-ec-42d8a7b027e7a4313734e62caffedc852989a4db.tar.gz |
spring: set boost PWM frequency to 32Khz
Push the PWM frequency outside the audio band to avoid audible whining.
Also fix the off-by-one in the PWM frequency computation.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
BRANCH=spring
BUG=chrome-os-partner:17583
TEST=manual : probe the PWM output with a scope.
Original-Change-Id: Ie1c8c5aed72bef46c8bac16c1bf3007e8e9573bb
Reviewed-on: https://gerrit.chromium.org/gerrit/45584
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
(cherry picked from commit f2df09d60259eb6abe00899925a64f5131dc2b10)
Change-Id: I6e28e1848b89581b65b15c596b01123f8dd1cea2
Reviewed-on: https://gerrit.chromium.org/gerrit/45591
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
-rw-r--r-- | board/spring/usb_charging.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/board/spring/usb_charging.c b/board/spring/usb_charging.c index d7ba332047..5c29af3e69 100644 --- a/board/spring/usb_charging.c +++ b/board/spring/usb_charging.c @@ -21,7 +21,7 @@ #include "tsu6721.h" #include "util.h" -#define PWM_FREQUENCY 10000 /* Hz */ +#define PWM_FREQUENCY 32000 /* Hz */ /* Console output macros */ #define CPUTS(outstr) cputs(CC_USBCHARGE, outstr) @@ -116,14 +116,14 @@ static void board_ilim_use_pwm(void) STM32_TIM_CR1(3) = 0x0000; /* - * CPU_CLOCK / PSC determines how fast the counter operates. + * CPU_CLOCK / (PSC + 1) determines how fast the counter operates. * ARR determines the wave period, CCRn determines duty cycle. - * Thus, frequency = CPU_CLOCK / PSC / ARR. + * Thus, frequency = CPU_CLOCK / (PSC + 1) / ARR. * * Assuming 16MHz clock and ARR=100, PSC needed to achieve PWM_FREQUENCY - * is: PSC = CPU_CLOCK / PWM_FREQUENCY / ARR + * is: PSC = CPU_CLOCK / PWM_FREQUENCY / ARR - 1 */ - STM32_TIM_PSC(3) = CPU_CLOCK / PWM_FREQUENCY / 100; /* pre-scaler */ + STM32_TIM_PSC(3) = CPU_CLOCK / PWM_FREQUENCY / 100 - 1; /* pre-scaler */ STM32_TIM_ARR(3) = 100; /* auto-reload value */ STM32_TIM_CCR1(3) = 100; /* duty cycle */ |