[SOLVED] 12Bit Pipeline ADC is not working in PIC24FJ128GC006

Status
Not open for further replies.

Thota Suresh Avionics

Member level 2
Joined
Jul 15, 2013
Messages
45
Helped
2
Reputation
4
Reaction score
2
Trophy points
8
Visit site
Activity points
345
I am uisng 12Bit Pipeline ADC in PIC24FJ128GC006,
MPLAB V8.8 IDE,
C30 compiler.

by using sample code from PIC24F family datasheet i am not able get output,

and also from silicon errata of this family some errors regarding sampling,calibration for this

work around process also done and still i am not able to get the output ...

am i missing some thing ?
this is my code and to see the output i am using terminal programming,in terminal i am getting output voltage as 0 volts..

Code:
include headers

volatile unsigned int channel_13;
volatile unsigned int channel_14;


int main()
{
 uart_init(); // initialized uart for terminal program
 ADC12_Init(); //12bit adc initialization

 while(1)
 {

 
  IFS0bits.AD1IF = 0; //Clear the ADC1 Interrupt Flag
  ADL0CONLbits.SAMP = 0;
  while(IFS0bits.AD1IF==0 );
   ADL0CONLbits.SAMP = 1; // Close the sample switch.
 
 
  channel_13 = ADRES0; // Read result for the channel 13.
  channel_14 = ADRES1; // Read result for the channel 14

  printf("%f V \t" ,channel_13);
  printf("%f V \n" ,channel_14);
 }
}


void ADC12_Init(void)
{

 TRISBbits.TRISB13 =1; //AN3 (RB13)
 ANSBbits.ANSB13 =1; 
 
 TRISBbits.TRISB14 =1; //AN2 (RB14)
 ANSBbits.ANSB14 =1;
  
 
 ADCON1=0;
// ADCON2=0x0300;
 ADCON3=0;


 ADCON2bits.PVCFG = 0; // AVdd
 ADCON2bits.NVCFG = 0; // AVss
 ADCON3bits.ADRC = 1; // using FRC
 ADCON3bits.ADCS = 8; // Tad 
 ADCON1bits.FORM = 0; // Output format is unsigned integer.
 ADCON2bits.BUFORG = 1; // Result buffer is an indexed buffer.
 ADCON2bits.BUFINT = 0; // No buffer interrupt.
 ADCON1bits.PWRLVL = 0; // Low power, reduced frequency operation.
 ADCON2bits.ADPWR = 3; // Module is always powered on.
 ADL0CONL = 0;
 ADL0CONH = 0;
 ADL0CONLbits.SLSIZE = 2-1; // Sample list length: 2 channels.
 ADL0CONHbits.ASEN = 1; // Enable auto-scan.
 ADL0CONHbits.SLINT = 1; // Interrupt after auto-scan completion.
 ADL0CONHbits.SAMC = 15; // Sample time is 15 TAD.
 ADL0CONLbits.SLTSRC = 0; // Single trigger generated when SAMP is cleared.
 ADL0PTR = 0; // Start from the first list entry.
 ADL0CONHbits.CM = 0; // Disable threshold compare.

 ADTBL0bits.ADCH = 13; //AN= Channel #13.
 ADTBL1bits.ADCH = 14; //AN= Channel #14.

 ADCON1bits.ADON = 1; // Enable A/D.

     while(ADSTATHbits.ADREADY == 0);
     ADL0CONLbits.SAMP = 1; // Close sample switch.
    ADL0CONLbits.SLEN = 1; // Enable sample list.
 printf("ADC12 Done\n");

}
 

problem solved... now my 12bit adc working absolutely fine

some changes in linker (.gld)
ADCON2 register must not be 0,
according to the silicon errata some other work around process included in code... problem solved working with accuracy 1milli volt difference

- - - Updated - - -

check working code from this URL

https://www.microchip.com/forums/m788767.aspx
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…