Hii,
I'm using twr-k70f120m kit (without MQX) with CW 10.6.4.
I'm trying to use the differential signal : PGA0DP_ADC0DP0_ADC1DP3
PGA0DM_ADC0DM0_ADC1DM3
I want some clarification on it like which channel should i use.
what should be adc mux select. bcoz differential adc pin are dedicated so i don't have to enable any gpio ??(or needed).
if anyone have any demo code on differential signal adc please share .
Thanks and regards
Ankur
Hi Ankur Chauhan
You can select the inputs channel for the ADC with the Status and Control Registers 1 (SC1). Over there you also have to specify the operation mode (Differential or single-ended).
In ADC0, the channel DAD0 is:
The inputs that you mentioned (PGA0DP_ADC0DP0_ADC1DP3 and PGA0DM_ADC0DM0_ADC1DM3) can be used for ADC0 or ADC1, so please consider it.
I made this quick code for a ADC0 initialization:
void ADC0_init(void)
{
/* Clock ADC0 */
SIM_SCGC6 |= SIM_SCGC6_ADC0_MASK;
/* Configure for Differential mode and select DAD0 (ADC0DP0/ADC0DM0)
* default value for ADCH is DAD0*/
ADC0_SC1A = ADC_SC1_DIFF_MASK;
/* Select 16-bit conversion and low porwer enable
* divider 8 from the input clock to ADC16 and long sample resolution */
ADC0_CFG1 = ADC_CFG1_MODE(0x03) | ADC_CFG1_ADLPC_MASK | ADC_CFG1_ADIV(0x03) | ADC_CFG1_ADLSMP_MASK;
/* Asynchronous clock output enable */
ADC0_CFG1 |= ADC_CFG1_ADICLK(0x03);
ADC0_CFG2 = ADC_CFG2_ADACKEN_MASK;
}
There isn´t any sample code on differential mode adc for the twr-70f120m, but you can search for the "KINETIS_120MHZ_SC", this package sample code include different demo apps for twr-70 and twr-60.
Hope this information can help you.
best regards
Jorge Alcala
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------