• AVR Freaks

Hot!ADC in PIC32MM0016

Author
kuku
Senior Member
  • Total Posts : 122
  • Reward points : 0
  • Joined: 2012/03/03 08:05:54
  • Location: 0
  • Status: offline
2019/07/18 09:19:23 (permalink)
0

ADC in PIC32MM0016

I have two matter with this ADC
 
1. I set Vref as AVss/AVdd (3.3V) but when I connect 1.018V to AN input, then ADC give me 1441. from my calculation it must be 1263 (ADC= 1,018/3,3 * 4096). 


2 How about 12bit mode?. Errata say that ADC must work only in 10 bit mode. When it lost result bit's?. I made simple test for both mode and it work fine.

ADC init code (don't trust coments- I change some register manually)

   AD1CON1 = 0x807C;

    // CSCNA enabled; BUFM disabled; SMPI Generates interrupt after completion of every 7th sample/conversion operation; OFFCAL disabled; VCFG AVDD/AVSS; BUFREGEN disabled;

   AD1CON2 = 0x418;

    // SAMC 14; EXTSAM disabled; ADRC PBCLK; ADCS 6;

   AD1CON3 = 0xA09;

    // CH0SA AN0; CH0NA AVSS;

   AD1CHS = 0x00;

    // CSS9 enabled; CSS8 enabled; CSS7 enabled; CSS6 enabled; CSS5 enabled; CSS4 disabled; CSS3 disabled; CSS2 disabled; CSS1 disabled; CSS0 disabled; CSS11 enabled; CSS10 enabled; CSS30 disabled; CSS29 disabled; CSS28 disabled;

   AD1CSS = 0xFE0;

    // ASEN disabled; WM Legacy operation; ASINT No interrupt; CM Less Than mode; BGREQ disabled; LPEN Full power;

   AD1CON5 = 0x00;

    // CHH2 disabled; CHH1 disabled; CHH0 disabled; CHH11 disabled; CHH10 disabled; CHH9 disabled; CHH8 disabled; CHH7 disabled; CHH6 disabled; CHH5 disabled; CHH4 disabled; CHH3 disabled;

   AD1CHIT = 0x00;

#1

2 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 6361
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: ADC in PIC32MM0016 2019/07/18 09:29:30 (permalink)
    0
    kuku
     
    ADC init code (don't trust coments- I change some register manually)


    Might I humbly suggest bad comments are worse than no comments.
    #2
    kuku
    Senior Member
    • Total Posts : 122
    • Reward points : 0
    • Joined: 2012/03/03 08:05:54
    • Location: 0
    • Status: offline
    Re: ADC in PIC32MM0016 2019/07/18 11:57:55 (permalink)
    0
    You're right, but I experimented with the code and wanted to copy it quickly, so I also took the comments and added the appropriate attention.
    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5