Ancy Muhammed
Newbie level 2
I have to read 8 ADC channels. For this I selected simultaneous sampling of 4 channels. But I got the reading greater than the expected value for all channels. Almost 100 digit difference are observed. If I change to sequential sampling by selecting SIMSAM bit 0, I got the correct value.
The ADC settings are given below
Could you please check the above issue. The ADC reading is made synchronised with PWM
The ADC settings are given below
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ADCON1bits.ADON = 0; // A/D converter is off ADCON1bits.ADSIDL = 0; // Continue module operation in Idle mode ADCON1bits.FORM = 0b00; // Data output format is integer ADCON1bits.SSRC = 0b011; // Motor Control PWM interval ends sampling and starts conversion ADCON1bits.SIMSAM = 1; // Samples CH0, CH1, CH2, CH3 simultaneously ADCON1bits.ASAM = 1; // Sampling begins immediately after last conversion completes ADCON2bits.VCFG = 0b000; // Voltage Reference Configuration bits A/DVREFH = AVdd, A/DVREFL = AVSS ADCON2bits.CSCNA = 0; // Do not scan inputs ADCON2bits.CHPS = 0b11; // Converts CH0, CH1, CH2 and CH3 ADCON2bits.SMPI = 0b0001; // Interrupts at the completion of conversion for each 2nd sample/convert sequence ADCON2bits.ALTS = 1; /* Uses MUX A input multiplexer settings for first sample, then alternate between MUX B and MUX A input multiplexer settings for all subsequent samples */ ADCON3bits.SAMC = 0b01100; // Auto-Sample Time bits 12TAD ADCON3bits.ADCS = 0b00011; // A/D Conversion Clock Select bits 4TCY // MUX A Multiplexer Setting bits ADCHSbits.CH123NA = 0b00; // CH1, CH2, CH3 negative input is VREF ADCHSbits.CH123SA = 1; // CH1 positive input is AN3, CH2 positive input is AN4, CH3 positive input is AN5 ADCHSbits.CH0NA = 0; // Channel 0 negative input is VREF ADCHSbits.CH0SA = 0b0010; // Channel 0 positive input is AN2 // MUX B Multiplexer Setting bits ADCHSbits.CH123NB = 0b11; // CH1 negative input is AN9, CH2 negative input is AN10, CH3 negative input is AN11 ADCHSbits.CH123SB = 1; // CH1 positive input is AN3, CH2 positive input is AN4, CH3 positive input is AN5 ADCHSbits.CH0NB = 0; // Channel 0 negative input is VREF ADCHSbits.CH0SB = 0b1000; // Channel 0 positive input is AN8 ADPCFG = 0xF8C3; // Analog Input Pin Configuration Control bits ADCSSL = 0x0000; // Skip ANx for input scan IFS0bits.ADIF = 0; // Clear ADC interrupt flag IPC2bits.ADIP = 0b101; // ADC interrupt priority is 5