S32K142_AD

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

S32K142_AD

928 Views
hanchengyu
Contributor I

I am using the AD function of S32k142,start AD function every 50us,and collect 5 channels every time.Now, I find that the voltage of the port being collected will be pulled down.

微信截图_20190520115138.png

Inside the red box,The high level voltage is pulled down to 4.1v,Under normal circumstances, the high level voltage should be 4.8v.I want to know why the voltage is pulled down and how to solve this problem.

The code:

void ADC_init(void)
{
PCC->PCCn[PCC_ADC0_INDEX] &=~ PCC_PCCn_CGC_MASK; /* Disable clock to change PCS */
PCC->PCCn[PCC_ADC0_INDEX] |= PCC_PCCn_PCS(1); /* PCS=1: Select SOSCDIV2 */
PCC->PCCn[PCC_ADC0_INDEX] |= PCC_PCCn_CGC_MASK; /* Enable bus clock in ADC */


ADC0->SC1[0] |= ADC_SC1_ADCH_MASK;         /* ADCH=1F: Module is disabled for conversions */
                                                                                 /* AIEN=0: Interrupts are disabled */
ADC0->CFG1 |= ADC_CFG1_ADIV_MASK
                             |ADC_CFG1_MODE(1);              /* ADICLK=0: Input clk=ALTCLK1=SOSCDIV2 */
                                                                                 /* ADIV=0: Prescaler=1 */
                                                                                 /* MODE=1: 12-bit conversion */

ADC0->CFG2 = ADC_CFG2_SMPLTS(12);          /* SMPLTS=12(default): sample time is 13 ADC clks */
ADC0->SC2 = 0x00000000;                                    /* ADTRG=0: SW trigger */
                                                                                  /* ACFE,ACFGT,ACREN=0: Compare func disabled */
                                                                                    /* DMAEN=0: DMA disabled */
                                                                                  /* REFSEL=0: Voltage reference pins= VREFH, VREEFL */
ADC0->SC3 = 0x00000000;                                    /* CAL=0: Do not start calibration sequence */
                                                                                  /* ADCO=0: One conversion performed */
                                                                                   /* AVGE,AVGS=0: HW average function disabled */
}

void adc_test()
{
ADC0->SC1[0]&=~ADC_SC1_ADCH_MASK;                                    /* Clear prior ADCH bits */
ADC0->SC1[0] = ADC_SC1_ADCH(9);                                               /* Initiate Conversion */
while(((ADC0->SC1[0] & ADC_SC1_COCO_MASK)>>ADC_SC1_COCO_SHIFT)==0){}
adc_result=ADC0->R[0];

ADC0->SC1[0]&=~ADC_SC1_ADCH_MASK;                                     /* Clear prior ADCH bits */
ADC0->SC1[0] = ADC_SC1_ADCH(8);                                                /* Initiate Conversion */
while(((ADC0->SC1[0] & ADC_SC1_COCO_MASK)>>ADC_SC1_COCO_SHIFT)==0){}
adc_result=ADC0->R[0];

ADC0->SC1[0]&=~ADC_SC1_ADCH_MASK;                                  /* Clear prior ADCH bits */
ADC0->SC1[0] = ADC_SC1_ADCH(0x0A);                                      /* Initiate Conversion */
while(((ADC0->SC1[0] & ADC_SC1_COCO_MASK)>>ADC_SC1_COCO_SHIFT)==0){}
adc_result=ADC0->R[0];

ADC0->SC1[0]&=~ADC_SC1_ADCH_MASK;                                  /* Clear prior ADCH bits */
ADC0->SC1[0] = ADC_SC1_ADCH(0x0C);                                       /* Initiate Conversion */
while(((ADC0->SC1[0] & ADC_SC1_COCO_MASK)>>ADC_SC1_COCO_SHIFT)==0){}
adc_result=ADC0->R[0];

ADC0->SC1[0]&=~ADC_SC1_ADCH_MASK;                                   /* Clear prior ADCH bits */
ADC0->SC1[0] = ADC_SC1_ADCH(0x0B);                                       /* Initiate Conversion */
while(((ADC0->SC1[0] & ADC_SC1_COCO_MASK)>>ADC_SC1_COCO_SHIFT)==0){}
adc_result=ADC0->R[0];
}

Labels (1)
0 Kudos
1 Reply

789 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

What is the source resistance of the measured signal?

Please see Section 6.4.1 ADC electrical specifications in the S32K1xx Datasheet rev.9.

And AN12217, S32K1xx ADC guidelines, spec and configuration, Section 2.2. Sources of error in ADC measurements

Thanks,

BR, Daniel

0 Kudos