• AVR Freaks

Hot!32MZ EF ADC measurement Issue

Author
GARETH_71
Senior Member
  • Total Posts : 145
  • Reward points : 0
  • Joined: 2006/11/18 13:46:50
  • Location: UK
  • Status: offline
2019/05/23 11:21:11 (permalink)
0

32MZ EF ADC measurement Issue

Hi All
 
RE: 2048EFH064
Uuugh! This ADC is ugly.
 
So, I have two voltages going to two different pins. One is set to ADC1, one is set to ADC7.
I am using scanning.
 
I am getting quite different voltages via the ADC results, even though I have measured the voltages on the pins with a 5 digit voltmeter and they are near as identical. For example, 2.4999 and 2.4998 yet the ADC shows 2.501 (okay!) and 2.599 - that is almost a 100mv different!
 
What have I tried? every which way the ADC can be configured in 12bit mode, slowing down TAD/SAMC to slowest possible etc etc, all with identical results. I have even changed the chip.
 
All voltages are driven directly from an opamp elsewhere on the board. SO why are these reading so different?
 
Actually I am using 8 analog inputs and these differences are everywhere.
 
Now I truly hope I have done something wrong, or missed something - but I have this horrible (yet regular) feeling that my microchip is not quite as it should be.
 
While I am on the subject - where is the documentation on the calibration registers? there is nothing in the datasheet other than a small note at the end of the list of registers: 
" 3 Before enabling the ADC, the user application must initialize the ADC calibration values by copying them from the factory-programmed DEVADCx Flash registers into the corresponding ADCxCFG registers"
 
Perhaps this is the problem? The calibration configuration is wrong. I have tried with and without this and get wildly different results, alas they are all very wrong (and still offset).
The examples etc do not even mention these registers.
 
Thoughts? Somebody please tell me I am an idiot! (roll on the replies with 'idiot' in them...)
 
:)
 
#1

4 Replies Related Threads

    MisterHemi
    Senior Member
    • Total Posts : 123
    • Reward points : 0
    • Joined: 2017/11/02 12:24:21
    • Location: 0
    • Status: offline
    Re: 32MZ EF ADC measurement Issue 2019/05/26 12:12:12 (permalink)
    0
     
    I forget where it's located in the datasheet but this is what I have:

    /* Calibrate the ADCs by using these values contained in the DEVADC registers */
    ADC0CFG = DEVADC0; // Load the calibration numbers into the ADCs
    ADC1CFG = DEVADC1;
    ADC2CFG = DEVADC2;
    ADC3CFG = DEVADC3;
    ADC4CFG = DEVADC4;
    ADC7CFG = DEVADC7;

     
     Hope that helps!
     

    My configuration:
    MacBook Pro (Retina, 15-inch, Mid 2015) with MacOS High Sierra (10.13.3) and MPLAB X IDE v4.15
     
    Curiosity PIC MZ EF, PIC24F Curiosity, and XPRESS EVAL BOARD (PIC16F18855).
    #2
    GARETH_71
    Senior Member
    • Total Posts : 145
    • Reward points : 0
    • Joined: 2006/11/18 13:46:50
    • Location: UK
    • Status: offline
    Re: 32MZ EF ADC measurement Issue 2019/05/28 00:16:14 (permalink)
    0
    Many thanks for that, I already have that but still wrong. I was hoping to have some more information on those registers so that I could look to calibrate for the errors in the ADC myself.
     
    #3
    GARETH_71
    Senior Member
    • Total Posts : 145
    • Reward points : 0
    • Joined: 2006/11/18 13:46:50
    • Location: UK
    • Status: offline
    Re: 32MZ EF ADC measurement Issue 2019/05/29 07:46:23 (permalink)
    0
     
    SOLVED! Don't quite know how or why, but after getting interrupts working properly, the results have sorted themselves out.
    (see my post on scanning adc notes)
    #4
    LostInSpace
    Super Member
    • Total Posts : 245
    • Reward points : 0
    • Joined: 2016/03/11 22:47:59
    • Location: 0
    • Status: offline
    Re: 32MZ EF ADC measurement Issue 2019/06/01 10:28:45 (permalink)
    0
    For completeness there is information on how to init the Calibration Registers in section 28.1 of the main PIC32MZ data sheet.
     
    Glad you got it working.
    #5
    Jump to:
    © 2019 APG vNext Commercial Version 4.5