Skip to content

[LPC1549] Improve AnalogIn Performance #1564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ void analogin_init(analogin_t *obj, PinName pin) {
LPC_SYSCON->SYSAHBCLKCTRL0 |= (1 << 28);
}

// select IRC as asynchronous clock, divided by 1
LPC_SYSCON->ADCASYNCCLKSEL = 0;
LPC_SYSCON->ADCASYNCCLKDIV = 1;

__IO LPC_ADC0_Type *adc_reg = (obj->adc < ADC1_0) ? (__IO LPC_ADC0_Type*)(LPC_ADC0) : (__IO LPC_ADC0_Type*)(LPC_ADC1);

// determine the system clock divider for a 500kHz ADC clock during calibration
Expand All @@ -90,8 +86,8 @@ void analogin_init(analogin_t *obj, PinName pin) {
adc_reg->CTRL = (1UL << 30) | (clkdiv & 0xFF);
while ((adc_reg->CTRL & (1UL << 30)) != 0);

// switch to asynchronous mode
adc_reg->CTRL = (1UL << 8);
// Sampling clock: SystemClock divided by 1
adc_reg->CTRL = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: Running the ADC at 72MHz (SystemCoreClock / 1) didn't appear to affect the readings on my test board. If issues arise in the future, SystemCoreClock can simply be scaled using the CLKDIV bits in the CTRL register.

}

static inline uint32_t adc_read(analogin_t *obj) {
Expand Down