Hi liwuquan,
I'm not expert in ADC programming - perhaps you should ask that in the MPC community - but according with MPC5744P Reference Manual ($36.5.1.1)
I quote:
"Programming the available Normal Conversion Mask Register(s) (ADC_NCMRn) selects the channel(s). Each channel can be individually enabled by setting a bit in the corresponding field of the NCMRn register. NCMR0 serves precision channels:
• 0 - 15 (ADC0)
• 0 - 15 (ADC1)
• 0 - 4, 10, 14 (ADC2)
• 0 - 7, 10 - 14 (ADC3)
The mask register(s) must be programmed before starting the conversion and cannot be changed until the conversion of all the selected channels ends. Conversion always starts from the lowest channel number selected and sequentially goes to the highest number." -- end of quote
Therefore you can't switch the function calls.
Anyhow, why would you do that ?
Hope it helps!
Daniel
Daniel,
Thank you for your quick answer.
Why I want to do that, I am thinking that what function ADC1_PadConfig_ChanSelect() does has nothing to do with what the function ADC1_Calibration() does. If so, then for my real motor control application, I would like to do the Calibration first, then configure ADC to CTU mode for the conversion and do the conversion.
Please let me know how function ADC1_PadConfig_ChanSelect() is related with the calibration, why it has to go ahead of function ADC1_Calibration();
Would you please also provide more NXP documentation to help me with MPC5744P ADC calibration?
Why I always prefer to posting my questions to NXP motor control community, the reasons are : first we are using MPC5744P for motor control application; second most time I can get quicker help from you.
Thank you.
Susan Li
Hi liwuquan
Thanks for your appreciation!
In the example you shown, the function ADC1_PadConfig_ChanSelect() { } writes in the ADC_1.NCMR0.B.CH6 register since it wants to calibrate for that specific analogue input (PTE12 pin). Therefore, according with the Reference Manual it has to be called prior to the void ADC1_Calibration(void)
It is normal that you first assign the ADC channel you want to calibrate and then perform the calibration. Otherwise it does not make sense. Am i missing something ?
Best regards,
Daniel