Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
Diff: targets/hal/TARGET_NXP/TARGET_LPC11U6X/analogin_api.c
- Revision:
- 336:cad63c80acb0
- Parent:
- 285:31249416b6f9
diff -r 6848febe3436 -r cad63c80acb0 targets/hal/TARGET_NXP/TARGET_LPC11U6X/analogin_api.c
--- a/targets/hal/TARGET_NXP/TARGET_LPC11U6X/analogin_api.c Fri Oct 03 16:45:07 2014 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC11U6X/analogin_api.c Mon Oct 06 09:15:06 2014 +0100
@@ -66,13 +66,15 @@
// Enable clock for ADC
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 13);
- // Start ADC self-calibration
- LPC_ADC->CTRL = (1UL << 30);
- do {
- tmp = LPC_ADC->CTRL;
- } while ((tmp & (1UL << 30)) != 0);
+ // Determine the clock divider for a 500kHz ADC clock during calibration
+ uint32_t clkdiv = (SystemCoreClock / 500000) - 1;
+
+ // Perform a self-calibration
+ LPC_ADC->CTRL = (1UL << 30) | (clkdiv & 0xFF);
+ while ((LPC_ADC->CTRL & (1UL << 30)) != 0);
- LPC_ADC->CTRL = 1; // Sampling clock: SystemClock divided by 1
+ // Sampling clock: SystemClock divided by 1
+ LPC_ADC->CTRL = 0;
}
static inline uint32_t adc_read(analogin_t *obj) {
