lpadc hangs at gain-calibrate on LPC55S69

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

lpadc hangs at gain-calibrate on LPC55S69

Jump to solution
680 Views
jgreen
Contributor III

Hi I'm using LPC55S69 and I'm trying the 'lpadc' example code from SDK.

In both the example of "lpcxpresso55s69_lpadc_polling" and "lpcxpresso55s69_lpadc_interrupt"

I notice in the file 'fsl_lpadc.c' the code to do ADC offset-calibration is disabled (and a fixed offset is used).

If I enable the offset calibration by setting 'DEMO_LPADC_DO_OFFSET_CALIBRATION true' then I find the function 

LPADC_DoOffsetCalibration() will be executed as expected, but I then find the function LPADC_DoAutoCalibration() will hang.

In the function LPADC_DoAutoCalibration(), after setting the bit to request gain calibration 'base->CTRL |= ADC_CTRL_CAL_REQ_MASK;' I find the GCC[n].RDY bits are never set, but it works fine when no offset-calibration is done before.

Any idea what is wrong to cause gain calibration to hang?

Tags (1)
0 Kudos
1 Solution
587 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi John,

 

I have replicated your issue. It seems sometimes the ADC_CTRL_CAL_REQ_MASK bit is not set correctly. I managed it to work by using a timeout. Please check the below code:

 

/* Request gain calibration. */
base->CTRL |= ADC_CTRL_CAL_REQ_MASK;
while ((ADC_GCC_RDY_MASK != (base->GCC[0] & ADC_GCC_RDY_MASK)) ||
           (ADC_GCC_RDY_MASK != (base->GCC[1] & ADC_GCC_RDY_MASK)))
{
      if (i > delay_num)
      {
              PRINTF("\rCalibration timed out reached\n");
              base->CTRL |= ADC_CTRL_CAL_REQ_MASK;
              i = 0;
      }
      i++;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

Please let me know if this works.

 

Best regards,

Felipe

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

View solution in original post

2 Replies
588 Views
FelipeGarcia
NXP Employee
NXP Employee

Hi John,

 

I have replicated your issue. It seems sometimes the ADC_CTRL_CAL_REQ_MASK bit is not set correctly. I managed it to work by using a timeout. Please check the below code:

 

/* Request gain calibration. */
base->CTRL |= ADC_CTRL_CAL_REQ_MASK;
while ((ADC_GCC_RDY_MASK != (base->GCC[0] & ADC_GCC_RDY_MASK)) ||
           (ADC_GCC_RDY_MASK != (base->GCC[1] & ADC_GCC_RDY_MASK)))
{
      if (i > delay_num)
      {
              PRINTF("\rCalibration timed out reached\n");
              base->CTRL |= ADC_CTRL_CAL_REQ_MASK;
              i = 0;
      }
      i++;
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

Please let me know if this works.

 

Best regards,

Felipe

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

587 Views
jgreen
Contributor III

Hi Felipe, yes I'm sure that will work (I haven't tried it yet).

I just think it strange this issue only occurs if zero-calibration is done first.

Thanks for your response - much appreciated.

Regards

Jon

0 Kudos