LPC55s69 LPADC Calibration code

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

LPC55s69 LPADC Calibration code

691 Views
HeMyFAE
NXP Employee
NXP Employee

S

hDear LPC55xx support,

Customer : I-Blades.

  I-blades was looking at the lpadc sample code to figure out how the calibration code works .After stepping through the code they realize that the sample code does not actual go thru the calibration procedure but simply writes to fixed values of 10 into the calibration offset register.

Q: Are those values specific for the eval Board ?

Snippet of Calibration code:

#if defined(FSL_FEATURE_LPADC_HAS_CTRL_CALOFS) && FSL_FEATURE_LPADC_HAS_CTRL_CALOFS
#if defined(FSL_FEATURE_LPADC_HAS_OFSTRIM) && FSL_FEATURE_LPADC_HAS_OFSTRIM
    /* Request offset calibration. */
    if (true == DEMO_LPADC_DO_OFFSET_CALIBRATION)
    {
        LPADC_DoOffsetCalibration(DEMO_LPADC_BASE);
    }
    else
    {
        LPADC_SetOffsetValue(DEMO_LPADC_BASE, DEMO_LPADC_OFFSET_VALUE_A, DEMO_LPADC_OFFSET_VALUE_B);
    }
#endif /* FSL_FEATURE_LPADC_HAS_OFSTRIM */
    /* Request gain calibration. */
    LPADC_DoAutoCalibration(DEMO_LPADC_BASE);
#endif /* FSL_FEATURE_LPADC_HAS_CTRL_CALOFS */

 

 

if you use the debugger and step thru this code you will see that the line :

 

  LPADC_SetOffsetValue(DEMO_LPADC_BASE, DEMO_LPADC_OFFSET_VALUE_A, DEMO_LPADC_OFFSET_VALUE_B);

 

is the only line that is executed.

As you can see from the code below the LPADC_DoAutoCAlibration is greyout  by the #if Defined at the top so there is no auto calibration taken place.

Q: what is the reason for not  calling the auto calibration in the demo code?

Q: If the customer want to use this calibration for his own board, can he just call it?

pastedImage_4.png

Labels (1)
0 Kudos
3 Replies

557 Views
HeMyFAE
NXP Employee
NXP Employee

hi XiangJun Rong,

i added the code into both interrupt and polling code, but when i ran it, it keep getting stuck on this while loop right here.

(See below screen capture).

Please advise!

pastedImage_1.png

0 Kudos

557 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, HyMai,

I think you can download the latest SDK package based on LPC55S69 SDK_2.6.3_LPCXpresso55S69.zip and use the latest MCUXpresso tools ver11.0.1, and load the lpadc_interrupt example. You do not need to change anything, it do calibration exactly  without any modification.

I have tried to debug, this is the result. of course, I can pass the calibration.

BR

XiangJun Rong

pastedImage_9.png

0 Kudos

557 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, HyMai,

I have tested the ADC calibration for LPC55S69, the calibration code works fine.

It is okay if you set the following calibration.

//#define DEMO_LPADC_DO_OFFSET_CALIBRATION false
#define FSL_FEATURE_LPADC_HAS_CTRL_CALOFS 1
#define FSL_FEATURE_LPADC_HAS_OFSTRIM 1
#define DEMO_LPADC_DO_OFFSET_CALIBRATION true

After you modified the code, the macro is like this:

/*******************************************************************************
 * Definitions
 ******************************************************************************/
#define DEMO_LPADC_BASE ADC0
#define DEMO_LPADC_IRQn ADC0_IRQn
#define DEMO_LPADC_IRQ_HANDLER_FUNC ADC0_IRQHandler
#define DEMO_LPADC_USER_CHANNEL 0U
#define DEMO_LPADC_USER_CMDID 1U /* CMD1 */
#define DEMO_LPADC_VREF_SOURCE kLPADC_ReferenceVoltageAlt2
//#define DEMO_LPADC_DO_OFFSET_CALIBRATION false
#define FSL_FEATURE_LPADC_HAS_CTRL_CALOFS 1
#define FSL_FEATURE_LPADC_HAS_OFSTRIM 1
#define DEMO_LPADC_DO_OFFSET_CALIBRATION true
#define DEMO_LPADC_OFFSET_VALUE_A 10U
#define DEMO_LPADC_OFFSET_VALUE_B 10U

/*******************************************************************************
 * Prototypes
 ******************************************************************************/

/*******************************************************************************
 * Variables
 ******************************************************************************/

.....................

Hope it can help you

BR

XiangJun Rong

0 Kudos