mirror of https://github.com/Desuuuu/klipper.git
lpc176x: Fix adc clock divisor
Commit 1096075d
changed CONFIG_CLOCK_FREQ to the actual cpu frequency,
but that commit failed to update adc.c accordingly. That made the adc
run 4 times slower. Make the corresponding change to adc.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
077c6f7e5e
commit
8d029ad652
|
@ -51,7 +51,7 @@ gpio_adc_setup(uint8_t pin)
|
|||
if (!is_enabled_pclock(PCLK_ADC)) {
|
||||
// Power up ADC
|
||||
enable_pclock(PCLK_ADC);
|
||||
uint32_t prescal = DIV_ROUND_UP(CONFIG_CLOCK_FREQ*4, ADC_FREQ_MAX) - 1;
|
||||
uint32_t prescal = DIV_ROUND_UP(CONFIG_CLOCK_FREQ, ADC_FREQ_MAX) - 1;
|
||||
LPC_ADC->ADCR = adc_status.adcr = (1<<21) | ((prescal & 0xff) << 8);
|
||||
LPC_ADC->ADINTEN = 0xff;
|
||||
adc_status.chan = ADC_DONE;
|
||||
|
@ -104,7 +104,7 @@ gpio_adc_sample(struct gpio_adc g)
|
|||
LPC_ADC->ADCR = adc_status.adcr | (1 << g.chan) | (1<<16);
|
||||
|
||||
need_delay:
|
||||
return ((64 * DIV_ROUND_UP(CONFIG_CLOCK_FREQ*4, ADC_FREQ_MAX)
|
||||
return ((64 * DIV_ROUND_UP(CONFIG_CLOCK_FREQ, ADC_FREQ_MAX)
|
||||
* ARRAY_SIZE(adc_status.samples)) / 4 + timer_from_us(10));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue