LPC822 measuring wrong value

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC822 measuring wrong value

936 Views
adamkulpa
Contributor I

Hi!
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");
       
       getValuesADC();
       
       putLineUART("MEAS value: ");
       itoa((int)adc_buffer[ADC_CHANNEL], buffer, 10);
       putLineUART(buffer);
       putLineUART("\n");
       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)
  {
    errorADC();
  }
}

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?

PS.

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

Best regards

Adam Kulpa

2 Replies

740 Views
adamkulpa
Contributor I

Hello,
I found that my power line was corrupted and the mcu had 2,55 V on Vdd pin. Strange ADC reading was caused by Vdd < VREFP. I manage to power mcu properly with 3,3 V, and after that everything works normally. Conclusion is: always check the adc working conditions Vdd >= VREFP.

 

Thank you for quick response.

 

Best regards
Adam Kulpa

0 Kudos

740 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Adam Kulpa ,

Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.
I was wondering if you can share a compile-able demo which can replicate the phenomenon, and also sharing the sch of own board will be better.

Have a great day,
TIC

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!