AnsweredAssumed Answered

ADC K64 output

Question asked by ahmed hrabi on Oct 12, 2016
Latest reply on Oct 19, 2016 by ahmed hrabi

Hi everyone, 

 

I'am using the ADC16 of the k64. 

I'am using ADC0_DP1/ADC0_DM1 as differential Analogic voltage inputs.

The problem that i'am always getting as result the same value (3.3v that is the Vref) even when i change the input voltage value on the ADC0_DP1. 

 

Here is my code : 


#define ADC16_BASEADDR ADC0  //ID
#define ADC16_CHANNEL 0u //SC1A
#define ADC16_CHANNEL_NUMBER 1u //CHANNEL 1 (DP1)

#define VREF_BRD 3.300
#define SE_16BIT 65536.0
volatile uint32_t g_Adc16ConversionValue = 0;

 

ADC16_GetDefaultConfig(&adc16ConfigStruct);
ADC16_Init(ADC16_BASEADDR , &adc16ConfigStruct);
ADC16_EnableHardwareTrigger(ADC16_BASEADDR , false); 
if (kStatus_Success == ADC16_DoAutoCalibration(ADC0)) {
PRINTF("\r\nADC16_DoAutoCalibration() Done.");
} else {
PRINTF("ADC16_DoAutoCalibration() Failed.\r\n");
}
adc16ChannelConfigStruct.channelNumber = ADC16_CHANNEL_NUMBER ;
adc16ChannelConfigStruct.enableInterruptOnConversionCompleted = false;
adc16ChannelConfigStruct.enableDifferentialConversion = true; // enable diff mode
while (1)
{

//start new conversion
ADC16_SetChannelConfig(ADC16_BASEADDR , ADC16_CHANNEL , &adc16ChannelConfigStruct);

//wait conversion

while (0U == (kADC16_ChannelConversionDoneFlag & ADC16_GetChannelStatusFlags(ADC16_BASEADDR , ADC16_CHANNEL )))
{
}

//read converted value in ADC0 result register
g_Adc16ConversionValue = ADC16_GetChannelConversionValue(ADC16_BASEADDR , ADC16_CHANNEL);
voltRead = (float)(g_Adc16ConversionValue * (VREF_BRD / SE_16BIT));
PRINTF("\r\nADC Voltage: %0.3f v\r\n", voltRead);
}

 

 

 

 

 

Outcomes