Re-calibrating ADC after start up

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

Re-calibrating ADC after start up

599 Views
sean_dvorscak
Contributor III

I am using an MKE18F512VLH16 MCU at 250MHz.  I have a set up where I use eDMA to collect samples from the ADC, and stuff them into an array for processing later on.

I calibrate the ADC at least once on every start up using the auto calibration function.  However, it would be beneficial if I could manually update the cal coefficients while the system is running.  I have a function that will receive these coefficients over a CAN bus, and writes the values into the registers.  After I receive the values that need to be written, I put them through a range check.  If they pass the check, I commit them to the ADC.  Currently the registers that I am writing to are:  CLPS, CLP0, CLP1, CLP2, CLP3, CLP9, CLPX, OFS, and G.

I am simply just writing to the registers, and letting the system resume its normal actions.  However, when I try writing to the registers, the system does not behave correctly.  Without getting too much into the nitty gritty details of the code, the DMA channel that collects the ADC samples is supposed to interrupt after so many samples are collected.  This is where I run into issues.

I am wondering if simply writing to registers and resuming normal operations is sufficient enough for re-calibrating the ADC?  If there is a guide that I can use to help me with this, that would also be helpful.  I have read App Note 2989(Design, Accuracy, and Calibration of Analog to Digital Converters on the MPC5500 Family), and App Note 5314(ADC Calibration on Kinetis E+ Microcontrollers).  Didn't really get too much out of it.

Any help is appreciated.  Thank you.

Labels (1)
0 Kudos
1 Reply

502 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Sean Dvorscak

 

To calibrate the ADC manually you can follow these steps:

   -Calibrate only one ADC instance  at a time

   -Set ADC clk to half the maximum specified frequency

   -Clear CLPS, CLP3 CLP2, CLP1, CLP0,CLPX and CLP9 registers by writing 0x0 into them.

   -Write 0x87 into ADC_SC3 register (This will set CAL=1b, AVGE=1b and AVGS=11b)

   -Wait calibration to finish in the COCO field of ADC_SC1 register.

 

When CAL=1, the ADC begins the calibration sequence and writes to the other registers automatically. After this you can restore your ADC configuration.

 

Let me know if this is helpful, if you have more questions do not hesitate to ask me.

Best regards,

Omar

0 Kudos