Loading previously generated ADC calibration values

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Loading previously generated ADC calibration values

ソリューションへジャンプ
2,003件の閲覧回数
adrian11
Contributor I

I'm working with KL16 ADC block. I want to be able to calibrate ADC once, save the values in flash, and then re-load them during the next boot without re-calibrating. According to the spec, this should be possible.

My calibration works perfectly, but loading of the registers does not. When restoring the values, I begin by running the adc configuration routine first, that sets up voltage reference, clock source, etc. Then, I simply loop through the registers 4003_B028 to 4003_B06C and copy the values from flash to those registers. I verified with memory view that all of the registers, including the control and status registers have the same values after the restoration of the calibration values, as they have after the calibration.

Am I missing something important here?

タグ(3)
0 件の賞賛
返信
1 解決策
1,737件の閲覧回数
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Please check my test code below:

   // REPEAT for BOTH ADC's.  However we will only 'use' the results from

    // the ADC wired to the Potentiometer on the Kinetis Tower Card.

    // Repeating for ADC1:

    ADC_Config_Alt(ADC1_BASE_PTR, &Master_Adc_Config);  // config ADC

ADC1 registers value is:

ADC register 1.png

    //ADC_Cal(ADC1_BASE_PTR);                    // do the calibration

    //do manual ADC1 calibratin here.

    manual_ADC1_CAL();

After manual calibration ADC1 registers value is:

ADC register 2.png

    // config the ADC again to default conditions

    ADC_Config_Alt(ADC1_BASE_PTR, &Master_Adc_Config);

After that code, ADC1 registers value is :

ADC register 3.png

I don't run the ADC calibration , just load the ADC calibration value into the related registers.

Wish it helps.


Have a great day,
best regards,

Ma Hui

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

元の投稿で解決策を見る

0 件の賞賛
返信
7 返答(返信)
1,736件の閲覧回数
bobpaddock
Senior Contributor III

I don't have a direct answer for your questions.

I am curious why you want to use stored values?

Won't the calibration values change with ambient environment?

Something that I've noticed while doing testing is that resetting a KL25 or KL27 the calibration values are different from reset to reset, sometimes radically different.

Have you noticed this as well?

0 件の賞賛
返信
1,736件の閲覧回数
adrian11
Contributor I

Here is some more concrete data to answer your question. following are calibration register values for 3 calibration cycles under the same conditions (same Voltage input). As you mentioned Bob, there is some difference in each one. To be honest, I can't tell if these are significant differences or not.

Screen Shot 2015-04-09 at 11.02.15 PM 1.pngScreen Shot 2015-04-09 at 11.03.46 PM.pngScreen Shot 2015-04-09 at 11.04.20 PM.png

0 件の賞賛
返信
1,737件の閲覧回数
adrian11
Contributor I

My ADC is connected to a POT. My calibration values are pretty similar, as long as the POT is in the same position. I want to be able to calibrate the device once in mfg, in controlled environment and then restore those values later.

0 件の賞賛
返信
1,737件の閲覧回数
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

Sorry for my later reply.

I had done a test. That should be ok for customer to load ADC calibration value to ADC module related registers.

Please check my test code below and the ADC conversion result is also OK.

void manual_ADC1_CAL(void)

{

    ADC1_OFS   = 0xFFFF;

    ADC1_PG    = 0x8309;

    ADC1_MG    = 0x8306;

    ADC1_CLPD  = 0x14;                 

    ADC1_CLPS  = 0x31;     

    ADC1_CLP4  = 0x303;

    ADC1_CLP3  = 0x187;     

    ADC1_CLP2  = 0xC4;  

    ADC1_CLP1  = 0x62;   

    ADC1_CLP0  = 0x31;    

    ADC1_CLMD  = 0x15;    

    ADC1_CLMS  = 0x31;  

    ADC1_CLM4  = 0x302;  

    ADC1_CLM3  = 0x186;  

    ADC1_CLM2  = 0xC2;  

    ADC1_CLM1  = 0x61;   

    ADC1_CLM0  = 0x30;   

}

Wish it helps.


Have a great day,
best regards,

Ma Hui

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

1,737件の閲覧回数
adrian11
Contributor I

Hello Ma,

Could you tell me what happens before and after you write to the calibration registers? Do you set up the rest of ADC before? Do you still trigger the real calibration and then overwrite the values? Or can you just overwrite the values whenever you want?

Thanks for running this test for me!

Here are my values that are read back from flash and loaded into ADC registers:Screen Shot 2015-04-09 at 10.34.49 PM.png

0 件の賞賛
返信
1,738件の閲覧回数
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Please check my test code below:

   // REPEAT for BOTH ADC's.  However we will only 'use' the results from

    // the ADC wired to the Potentiometer on the Kinetis Tower Card.

    // Repeating for ADC1:

    ADC_Config_Alt(ADC1_BASE_PTR, &Master_Adc_Config);  // config ADC

ADC1 registers value is:

ADC register 1.png

    //ADC_Cal(ADC1_BASE_PTR);                    // do the calibration

    //do manual ADC1 calibratin here.

    manual_ADC1_CAL();

After manual calibration ADC1 registers value is:

ADC register 2.png

    // config the ADC again to default conditions

    ADC_Config_Alt(ADC1_BASE_PTR, &Master_Adc_Config);

After that code, ADC1 registers value is :

ADC register 3.png

I don't run the ADC calibration , just load the ADC calibration value into the related registers.

Wish it helps.


Have a great day,
best regards,

Ma Hui

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

0 件の賞賛
返信
1,737件の閲覧回数
adrian11
Contributor I

Thank you so much for your patience. I was able to figure out my problem. I had an issue elsewhere in my application that was skewing my results.

0 件の賞賛
返信