S32K148 ADC Config

cancel
Showing results for 
Search instead for 
Did you mean: 

S32K148 ADC Config

Jump to solution
243 Views
linglei_meng
Contributor II

Hello NXP team,

      We are using ADC1 in our project. I am configured the 26 channel of ADC1 according to the example and detected the voltage, but I don't get the value in the data register. Please help to check whether I have to configure it correctly.

 

ADC_DRV_ConfigConverter(INST_ADCONV1, &adConv1_ConvConfig0);
ADC_DRV_AutoCalibration(INST_ADCONV1);

/* Configure ADC channel and software trigger a conversion */
ADC_DRV_ConfigChan(INST_ADCONV1, 26U, &adConv1_ChnConfig0);
/* Wait for the conversion to be done */
ADC_DRV_WaitConvDone(INST_ADCONV1);

/* Store the channel result into a local variable */
ADC_DRV_GetChanResult(INST_ADCONV1, 26U, &adcRawValue);

 

 

#include "adConv1.h"

/*! adConv1 configuration structure */
const adc_converter_config_t adConv1_ConvConfig0 = {
.clockDivide = ADC_CLK_DIVIDE_4,
.sampleTime = 12U,
.resolution = ADC_RESOLUTION_12BIT,
.inputClock = ADC_CLK_ALT_1,
.trigger = ADC_TRIGGER_SOFTWARE,
.pretriggerSel = ADC_PRETRIGGER_SEL_PDB,
.triggerSel = ADC_TRIGGER_SEL_PDB,
.dmaEnable = false,
.voltageRef = ADC_VOLTAGEREF_VREF,
.continuousConvEnable = false,
.supplyMonitoringEnable = false,
};

const adc_chan_config_t adConv1_ChnConfig0 = {
.interruptEnable = false,
.channel = ADC_INPUTCHAN_EXT26,
};

const adc_compare_config_t adConv1_HwCompConfig0 = {
.compareEnable = false,
.compareGreaterThanEnable = false,
.compareRangeFuncEnable = false,
.compVal1 = 0U,
.compVal2 = 0U,
};

const adc_average_config_t adConv1_HwAvgConfig0 = {
.hwAvgEnable = false,
.hwAverage = ADC_AVERAGE_4,
};


/* END adConv1. */

0 Kudos
1 Solution
216 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

 

when Software Trigger mode is enabled, configuring control channel index 0, implicitly triggers a new conversion on the selected ADC input channel (defined in adConv1_ChnConfig0)Therefore, ADC_DRV_ConfigChan can be used for sw-triggering conversions. Thus you should use rather
 
ADC_DRV_ConfigChan(INST_ADCONV1, 0U, &adConv1_ChnConfig0);
ADC_DRV_GetChanResult(INST_ADCONV1, 0U, &adcRawValue);
 
BR, Petr

View solution in original post

0 Kudos
2 Replies
217 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

 

when Software Trigger mode is enabled, configuring control channel index 0, implicitly triggers a new conversion on the selected ADC input channel (defined in adConv1_ChnConfig0)Therefore, ADC_DRV_ConfigChan can be used for sw-triggering conversions. Thus you should use rather
 
ADC_DRV_ConfigChan(INST_ADCONV1, 0U, &adConv1_ChnConfig0);
ADC_DRV_GetChanResult(INST_ADCONV1, 0U, &adcRawValue);
 
BR, Petr

View solution in original post

0 Kudos
210 Views
linglei_meng
Contributor II

Thanks, your reply was of great help to me.

0 Kudos