S32k311 ADC module for MCAL

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

S32k311 ADC module for MCAL

1,430 Views
dhanabharathi
Contributor II

Hello @nxp 

  i am configuring ADC module for S32k31xevb- q100. i am using Autosar based MCAL layer configuration. in my case i am using software trigger without Interrupt method.  it is entering in to this function but my ADc value is not converting Adc_Sar_Ip_StartConversion(PhysicalHwUnitId, ADC_SAR_IP_CONV_CH AIN_NORMAL); what will be reason for this?

Tags (3)
0 Kudos
Reply
14 Replies

1,366 Views
dhanabharathi
Contributor II

hi @Senlent 
ok, Thankyou.
Another one problem.
when read data via analog pin. the VREF is always it taking 2.5 v only. I need 3.3v or 5v Vref. where i need to configure this? i can't set the Vref voltage. the configuration setting is inactive. i attached image for your reference

0 Kudos
Reply

1,349 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@dhanabharathi

I'm not sure what you mean. Shouldn't VREF be fixed? I

sn't it determined during hardware design?

If I'm misunderstanding your question, please let me know.

0 Kudos
Reply

1,342 Views
dhanabharathi
Contributor II

Hi @Senlent ,
 
   I will explain clearly My ADC reading seems to be calculated using the internal 2.5 V reference, but my input uses a 3.3 V reference (potentiometer on 5 V). How do I change the ADC reference from 2.5 V to 5 V so that the calculation V_measured = (ADC_value / (2^n − 1)) × Vref uses 5V?

Tags (3)
0 Kudos
Reply

1,309 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@dhanabharath

"My ADC reading seems to be calculated using the internal 2.5 V reference"

Unless there is a problem with your VREFH pins, this is not possible

 

The ADC reference voltage VREF cannot be modified via software.

This is related to your current external voltage selections for VREFH and VREFL pins.

If you are referring to how to modify the external ADC reference voltage in hardware, then you

need to review your hardware design and modify it.

0 Kudos
Reply

1,302 Views
dhanabharathi
Contributor II

hello @Senlent 

   ok. i understood.

I verified that VREFH is 5.0 V. However, when I feed 4.0 V into the ADC, the conversion result is off from the expected value for a 5 V reference. Could you help me review potential causes (reference selection, calibration, sampling time, or pin routing)?

Tags (3)
0 Kudos
Reply

1,300 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@dhanabharathi

Share your whole project and i will take time to test it.

0 Kudos
Reply

1,279 Views
dhanabharathi
Contributor II

Hi @Senlent ,

  i have attached the project file.

Tags (3)
0 Kudos
Reply

1,203 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@dhanabharathi

I see no problem with your configuration, but some mistake in your code.

Issues 1.

#define ADC_BANDGAP 5980U /* Vbandgap ~ 1.2V on 14 bits resolution, 3.3V VrefH */

#else

#define ADC_BANDGAP 3932U /* Vbandgap ~ 1.2V on 14 bits resolution, 5V VrefH */

#endif

 

if your VREF is 5V , then the ADC_BANDGAP is 3932, not 5980.

 

Issues 2.

if ((ResultBufferDma[0u] >> 1U != AdcReadGroupResult[0u]) || \
(ResultBufferDma[1u] >> 1U != AdcReadGroupResult[1u]) || \
(ResultBufferDma[2u] != RESULT_BUFF_VAL) || \
(AdcReadGroupResult[2u] != ADC_RESULT_BUFF_VAL) || \
(ADC_TOLERANCE((ResultBufferDma[0u] >> 1U), ADC_BANDGAP)) || \
(ADC_TOLERANCE((ResultBufferDma[1u] >> 1U), ADC_VREFH)) \
)

You should delete these two lines of code. The original demo only set up two sampling channels, but you are currently using 4 sampling channels. This judgment will cause you to be unable to perform the next sampling.

 

 

0 Kudos
Reply

1,074 Views
dhanabharathi
Contributor II

Hello @Senlent 

  I followed your steps , still the same problem persists

Tags (3)
0 Kudos
Reply

1,020 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@dhanabharathi

The test hardware base on S32K31XEVB, and the result is right on myside.

I attached the project and the test result for your reference.

2025-10-23_13-35-45.png

0 Kudos
Reply

1,013 Views
dhanabharathi
Contributor II
hello @Senlent,

I will check my side again and i will let you know
0 Kudos
Reply

1,316 Views
dhanabharathi
Contributor II

Hi @Senlent ,

   No, i didn't get your point.

Tags (3)
0 Kudos
Reply

1,336 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@dhanabharathi

vrefh and vrefl are the high and low reference voltage points of the ADC, corresponding to the vrefh and vrefl pins of the pins

Senlent_0-1760598697496.png

Can you understand my explanation?

 

 

 

 

 

0 Kudos
Reply

1,393 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@dhanabharathi

You didn't add and configurate "Rm" component in your project.

Senlent_0-1760348275804.png

 

0 Kudos
Reply