Adam Kulpa

LPC822 measuring wrong value

Discussion created by Adam Kulpa on Jan 19, 2018
Latest reply on Jan 22, 2018 by Adam Kulpa

I'm working with NXP LPC822M101JDH20J and I'm trying to read adc values from PIO_23/ADC_3 pin with build in ROM ADC API. The Code attached below.

Constant signal is connected to PIO_23 pin and his value is 2,29 V. Reference voltage is 3,0 V on pin VREFP.


ADC hardware is configured as follow:

- 12 bit resolution

- clock: ADC_MAX_SAMPLE_RATE (with system clock: 30 MHz, sample: 1,2 M sample/s)

- sequential mode on channel 3

- polling mode


I'm able to perform analog to digital conversion, except that values are wrong when I do continuous code execution (in loop).

     while (1)
       putLineUART("MEAS: start\n");
       putLineUART("MEAS value: ");
       itoa((int)adc_buffer[ADC_CHANNEL], buffer, 10);
       putLineUART("MEAS: end\n");
static void getValuesADC()
  volatile uint32_t regVal;
  ADC_PARAM_T adc_param;
  ErrorCode_t err_code;

  /* ADC Param for SEQA read */
  adc_param.buffer = (uint32_t*) adc_buffer;
  adc_param.driver_mode = DRIVER_MODE_POLLING; /* Polling Mode */
  adc_param.seqa_hwtrig = 0;
  adc_param.adc_cfg = &adc_cfg; /* ADC Config */
  adc_param.comp_flags = 0;

  err_code = LPC_OK;
  err_code |= LPC_ADCD_API->adc_seqa_read(adc_handle, &adc_param);
  if (err_code != LPC_OK)


Result value is 3839 in decimal but due conversion, i should got (2,29/3,0) x 4095 = 3125 result in decimal.

The difference is 714 points, in voltage (714/4095)*3,0V = 0.52 V. Error is too much.


While in debug step mode i got proper result value 3135 which is close to calculated.


I tried to add delay between readings, but I observed no effect - still wrong values.


Does strange behavior of the ADC can be evoked by wrong configuraction or usage?

How ROM API works in polling mode eg. function adc_seqa_read() is it blocking ?

Can someone explain me why in continuous execuction i got higher values?



I also tried code from the example with LPC OPEN, but also ocure strange behavior of reading.


Best regards


Adam Kulpa