1957633_en-US

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

1957633_en-US

1957633_en-US

ADC1 is not working on S32K148

Hello,

I am using an S32K148 development board and I am trying to use ADC0 and ADC1. ADC0 is working properly but from some reason, I am not able to use ADC1, it seems like this is not enabled. The get_adc1_data() is printing any time value 0

Do you have any suggestion?

I am using the following code

#define INST_ADC_CONFIG_1 (0U)
#define INST_ADC_CONFIG_2 (1U)


const adc_converter_config_t adc_config_1_ConvConfig0 = {
    .clockDivide = ADC_CLK_DIVIDE_2,
    .sampleTime = 255U,
    .resolution = ADC_RESOLUTION_8BIT,
    .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 adc_config_1_ChnConfig0 = {
    .interruptEnable = true,
    .channel = ADC_INPUTCHAN_EXT17
};



const adc_converter_config_t adc_config_2_ConvConfig0 = {
    .clockDivide = ADC_CLK_DIVIDE_2,
    .sampleTime = 255U,
    .resolution = ADC_RESOLUTION_8BIT,
    .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 adc_config_2_ChnConfig0 = {
    .interruptEnable = true,
    .channel = ADC_INPUTCHAN_EXT13
};


void ADC_init()
{
    /* Initialize ADC */
    ADC_DRV_ConfigConverter(INST_ADC_CONFIG_1, &adc_config_1_ConvConfig0);
    ADC_DRV_AutoCalibration(INST_ADC_CONFIG_1);
 
    /* Initialize ADC */
    ADC_DRV_ConfigConverter(INST_ADC_CONFIG_2, &adc_config_2_ConvConfig0);
    ADC_DRV_AutoCalibration(INST_ADC_CONFIG_2);
}
 
void get_adc0_data() {
 
    uint16_t adcRead;
 
    (void) data;
    (void) len;
 
    ADC_DRV_ConfigChan(INST_ADC_CONFIG_1, 0U, &adc_config_1_ChnConfig0);
    ADC_DRV_WaitConvDone(INST_ADC_CONFIG_1);
 
    /* Store the channel result into a local variable adcRead*/
    ADC_DRV_GetChanResult(INST_ADC_CONFIG_1, 0U, &adcRead);
 
    printf("ADC0 data = %d\n\r>", adcRead);
}
 
void get_adc1_data() {
 
    uint16_t adcRead;
 
    (void) data;
    (void) len;
 
    ADC_DRV_ConfigChan(INST_ADC_CONFIG_2, 1U, &adc_config_2_ChnConfig0);
    ADC_DRV_WaitConvDone(INST_ADC_CONFIG_2);
 
    /* Store the channel result into a local variable adcRead*/
    ADC_DRV_GetChanResult(INST_ADC_CONFIG_2, 1U, &adcRead);
 
    printf("water temp is = %d\n\r>", adcRead);
 }
Re: ADC1 is not working on S32K148Thank you very much. It was working!Re: ADC1 is not working on S32K148

Hi@mcristian

please change the below hightlight part to 0

Senlent_0-1726832562956.png


Re: ADC1 is not working on S32K148

Hello, Thanks for reply. You can find the project attached

Re: ADC1 is not working on S32K148

Hi@mcristian

Can you provide me with a working project so that I can reproduce your problem?

Tags (1)
No ratings
Version history
Last update:
‎11-21-2025 11:06 AM
Updated by: