Skip to content
Permalink
Browse files

drivers: pwm: pwm_nrf5_sw: Fix calculation of cycles per second

The nRF5x HF timer base frequency is 16 MHz, not 16777216 Hz.

The improved accurracy of the PWM signal was verified with an
oscilloscope on a BBC micro:bit.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
  • Loading branch information...
henrikbrixandersen authored and carlescufi committed May 31, 2018
1 parent ebbb744 commit f5310d5b5463f3a2f004dd809b46834f54296814
Showing with 1 addition and 1 deletion.
  1. +1 −1 drivers/pwm/pwm_nrf5_sw.c
@@ -208,7 +208,7 @@ static int pwm_nrf5_sw_get_cycles_per_sec(struct device *dev, u32_t pwm,
config = (struct pwm_config *)dev->config->config_info;

/* HF timer frequency is derived from 16MHz source and prescaler is 0 */
*cycles = 16 * 1024 * 1024;
*cycles = 16000000UL;

return 0;
}

0 comments on commit f5310d5

Please sign in to comment.
You can’t perform that action at this time.