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?
Solved! Go to Solution.
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.
-------------------------------------------------------------------------------
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.
-------------------------------------------------------------------------------
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