AnsweredAssumed Answered

LPC4337 10bits ADC to sample audio at 22ksps

Question asked by Jose Motta on May 16, 2017

Hello everyone, I'm on a current embedded audio project using LPC4337.

I need to sample a voice audio signal (low fi), then filter it with noise cancelling algorithm and finally store it into an SD card and push it to the DAC for online monitoring.

How can I configure its ADC sampling time to achieve 22ksps? I'm not sure if I have to use a timer or I can directly set up ADC sampling time with Chip_ADC_SetSampleRate function.


Use Manual says:


Table 1114.   A/D Control register (CR)

Bits15:8 /// CLKDIV

The ADC clock is divided by the CLKDIV value plus one to produce the clock
for the A/D converter, which should be less than or equal to 4.5 MHz. Typically,
software should program the smallest value in this field that yields a clock of
4.5 MHz or slightly less, but in certain cases


So, in order to achieve 22000sps is it OK to use the following function on the ADC driver code?

* @brief Set the ADC Sample rate
* @param pADC : The base of ADC peripheral on the chip
* @param ADCSetup : ADC setup structure to be modified
* @param rate : Sample rate, should be set so the clock for A/D converter is less than or equal to 4.5MHz.
* @return Nothing
void Chip_ADC_SetSampleRate(LPC_ADC_T *pADC, ADC_CLOCK_SETUP_T *ADCSetup, uint32_t rate)
uint8_t div;
uint32_t cr;


ADCSetup->adcRate = rate;
div = getClkDiv(pADC, ADCSetup->burstMode, rate, (11 - ADCSetup->bitsAccuracy));
cr |= ADC_CR_CLKDIV(div);
cr |= ADC_CR_BITACC(ADCSetup->bitsAccuracy);
pADC->CR = cr;


I'm asking this because I'm unable to get the right sampling time when changing the rate parameter on Chip_ADC_SetSampleRate function.

It seems that I have to choose a value of 400000 which will drive an ADC clock close to 4.5MHz. If that's the case, how can I obtain a desired sampling rate, such as 22000Hz or even lower?


Thanks in advance for your kind responses.




Original Attachment has been moved to: