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

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

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

1,784件の閲覧回数
jackxu
Contributor III

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 

 

165560_165560.pngpastedImage_11.png

165561_165561.pngpastedImage_12.png

165562_165562.pngpastedImage_13.png

 

Thanks in advance!

-Jack

ラベル(1)
4 返答(返信)

1,331件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Jack,

This is my opinion. You can use both single-ended mode(DIFF bit is cleared) and differential mode(DIFF bit is set) to measure the temperature sensor, but the formula is slight different.

You do not list the part number, I assume that you use K64, Pls refer to Table 30. 16-bit ADC characteristics (VREFH = VDDA, VREFL = VSSA) (continued) in data sheet of K64.

The temperature slope m is 1.62/C typically, the temperature voltage in 25 degree Vtemp25 is 716mV typically.

The temperature Temp=Vtemp-Vtemp25/m.

If you use single-ended mode with DIFF bit cleared, you can use the formula to compute the voltage from digital sample in 16 bits mode.

Vtemp=sample*3.3V/65535.

If you use differential mode with DIFF bit set, you can use the formula to compute the voltage

Vtemp=sample*3.3V/32768.

per data sheet requirement, the ADC conversion clock should be less than  3 MHz.

Furthermore, the an3031 is helpful.

http://cache.nxp.com/files/microcontrollers/doc/app_note/AN3031.pdf?fsrch=1&sr=1&pageNum=1 

Hope it can help you.

BR

XiangJun Rong

1,331件の閲覧回数
jackxu
Contributor III

Hi XiangJun.Rong

Thanks for your quick answer and advice.

I have read the an3031, and refers to many details about the temp sensor, but i can not figure out how to connect the temper sensor with the single-ended or differential mode ADC channel. if temper sensor using differential mode channel, then how to differ DADP and DADM, also how to figure out the channel, just like following

   adc16ChannelConfigStruct.channelNumber = DEMO_ADC16_USER_CHANNEL;

   #define DEMO_ADC16_USER_CHANNEL 8U

pastedImage_11.png

Thanks in advance!

-Jack

0 件の賞賛
返信

1,331件の閲覧回数
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Jack,

The temperature sensor is "a P-N transistor junction with temperature dependent properties acting as an
embedded temperature sensor", the temperature sensor is embeded in the processor internally, you do not need select pin assignment, you just need select channel 26, the DIFF bit can be either  set or cleared, it is okay.

Hope it can help you.

BR

Xiangjun Rong

1,331件の閲覧回数
jackxu
Contributor III

Hi xiangjun.rong,

Got it, channel 26! temp sensor!  and i'll take a try tomorrow, ^_^, Thanks!

-Jack

0 件の賞賛
返信