12Bit Pipeline ADC is not working in PIC24FJ128GC006

12Bit Pipeline ADC is not working in PIC24FJ128GC006

Postby Thota_Suresh » Fri Sep 26, 2014 1:38 pm

http://www.microchip.com/forums/m788767.aspx

From above URL I also got the same problem with Pic24fj128GC006, i am using c30 compiler


http://www.microchip.com/forums/m757012.aspx

according to the above URL issue i included headers(.h), linker (.gld) files from XC16 compiler's PIC24F support files.

but still my 12bit ADC not working..

to see the result i included terminal programming it showing the output as 0 volts
am i missing something else please help me..



Code: Select all
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");

}




I need to read the 10K resistor voltage ...
Output looks like below attachment in terminal ...
Attachments
Capture.PNG
Capture.PNG (19.06 KiB) Viewed 4605 times
Thota_Suresh
 
Posts: 6
Joined: Tue Sep 23, 2014 7:41 am

Re: 12Bit Pipeline ADC is not working in PIC24FJ128GC006

Postby Thota_Suresh » Sat Sep 27, 2014 12:09 pm

Problem solved...my adc is working fine now

http://www.microchip.com/forums/m788767.aspx
Thota_Suresh
 
Posts: 6
Joined: Tue Sep 23, 2014 7:41 am

Re: 12Bit Pipeline ADC is not working in PIC24FJ128GC006

Postby AussieSusan » Mon Sep 29, 2014 3:32 am

I know it might be a pain, but I suggest that you make a post here to describe (briefly) the solution.
I the past, links to the Microchip site have been 'lost', especially when they do upgrades to their web site (and I believe they have another upgrade in the pipeline) and so those links might end up pointing to nothing.
Susan
AussieSusan
Verified identity
 
Posts: 157
Joined: Mon Jun 16, 2014 4:45 am
PIC experience: Experienced Hobbyist


Return to ADC & Comparators

Who is online

Users browsing this forum: No registered users and 3 guests