Dear Team,
I am having an accuracy problem reading the voltage value using the adc of the s32k144, so I have a question.
I used an op amp on the front to read a voltage of around 240.31mV.
Two points were measured with a multimeter.
1. When I measured pin 1 of the opamp side, I read 240.31mV voltage.
2. When I measured ADC0 13 on pin 45 of s32k144 MCU, I read 240.31mV voltage.
I read the ADC value using S32DS SDK, but the value is incorrect.
I am attaching a code and picture of setup.
What's wrong?
#############################################################
/* Including necessary module. Cpu.h contains other modules needed for compiling.*/
#include "Cpu.h"
volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */
#include "stdint.h"
#define ADC_INSTANCE 0UL
#define ADC_CHN 13U
#define ADC_VREFH 5.0f
#define ADC_VREFL 0.0f
int main(void)
{
/* Write your local variable definition here */
uint16_t adcRawValue;
uint16_t adcMax;
float adcValue = 0.0f;
adcMax = (uint16_t) (1 << 12);
/* Write your code here */
/* For example: for(;;) { } */
CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);
PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
DEV_ASSERT(PackV_ADC_ConvConfig0.channel == ADC_CHN);
ADC_DRV_ConfigConverter(ADC_INSTANCE, &PackV_ADC_ConvConfig0);
ADC_DRV_AutoCalibration(ADC_INSTANCE);
while(1)
{
/* Configure ADC channel and software trigger a conversion */
ADC_DRV_ConfigChan(ADC_INSTANCE, 0U, &PackV_ADC_ChnConfig0);
/* Wait for the conversion to be done */
ADC_DRV_WaitConvDone(ADC_INSTANCE);
/* Store the channel result into a local variable */
ADC_DRV_GetChanResult(ADC_INSTANCE, 0U, &adcRawValue);
/* Process the result to get the value in volts */
adcValue = ((float) adcRawValue / adcMax) * (ADC_VREFH - ADC_VREFL);
OSIF_TimeDelay(1000);
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
######################################################################
error print



Regards,
DJ LEE