AnsweredAssumed Answered

ADC Init -- Temp Sensor -- DADP0 & DADPM0 as Input -- Example Better

Question asked by Jack Xu on Oct 7, 2016
Latest reply on Oct 10, 2016 by Jack Xu

Hi there,

 

I can init a adc channel as following

 

   ADC16_GetDefaultConfig(&adc16ConfigStruct);
   ADC16_Init(DEMO_ADC16_BASE, &adc16ConfigStruct);
   ADC16_EnableHardwareTrigger(DEMO_ADC16_BASE, false);                /* Make sure the software trigger is used. */
#if defined(FSL_FEATURE_ADC16_HAS_CALIBRATION) && FSL_FEATURE_ADC16_HAS_CALIBRATION
   if (kStatus_Success == ADC16_DoAutoCalibration(DEMO_ADC16_BASE))
   {
        PRINTF("ADC16_DoAutoCalibration() Done.\r\n");
   }
   else
   {
      PRINTF("ADC16_DoAutoCalibration() Failed.\r\n");
   }
#endif /* FSL_FEATURE_ADC16_HAS_CALIBRATION */
   adc16ChannelConfigStruct.channelNumber = DEMO_ADC16_USER_CHANNEL;
   adc16ChannelConfigStruct.enableInterruptOnConversionCompleted = false;
#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
   adc16ChannelConfigStruct.enableDifferentialConversion = false;
#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */

 

#define DEMO_ADC16_USER_CHANNEL 8U

 

typedef struct _adc16_channel_config
{
   uint32_t channelNumber
   bool enableInterruptOnConversionCompleted; 
#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
   bool enableDifferentialConversion; /
#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
} adc16_channel_config_t;

 

void ADC16_SetChannelConfig(ADC_Type *base, uint32_t channelGroup, const adc16_channel_config_t *config)
{
   assert(channelGroup < ADC_SC1_COUNT);
   assert(NULL != config);

   uint32_t sc1 = ADC_SC1_ADCH(config->channelNumber); /* Set the channel number. */

#if defined(FSL_FEATURE_ADC16_HAS_DIFF_MODE) && FSL_FEATURE_ADC16_HAS_DIFF_MODE
   if (config->enableDifferentialConversion)
   {
      sc1 |= ADC_SC1_DIFF_MASK;
   }
#endif /* FSL_FEATURE_ADC16_HAS_DIFF_MODE */
   if (config->enableInterruptOnConversionCompleted)
   {
      sc1 |= ADC_SC1_AIEN_MASK;
   }
   base->SC1[channelGroup] = sc1;
}

 

But how to Init and using the temp sensor, also how to init and using the DADP & DADM as normal ADC pin 

 

 

Thanks in advance!

-Jack

Outcomes