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?
解決済! 解決策の投稿を見る。
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_Cal(ADC1_BASE_PTR); // do the calibration
//do manual ADC1 calibratin here.
manual_ADC1_CAL();
After manual calibration ADC1 registers value is:
// config the ADC again to default conditions
ADC_Config_Alt(ADC1_BASE_PTR, &Master_Adc_Config);
After that code, ADC1 registers value is :
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!
-----------------------------------------------------------------------------------------------------------------------
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?
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.
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.
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!
-----------------------------------------------------------------------------------------------------------------------
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:
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_Cal(ADC1_BASE_PTR); // do the calibration
//do manual ADC1 calibratin here.
manual_ADC1_CAL();
After manual calibration ADC1 registers value is:
// config the ADC again to default conditions
ADC_Config_Alt(ADC1_BASE_PTR, &Master_Adc_Config);
After that code, ADC1 registers value is :
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!
-----------------------------------------------------------------------------------------------------------------------
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.