• AVR Freaks

Hot!PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V

Author
jc999
Starting Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2017/10/08 07:23:13
  • Location: 0
  • Status: offline
2019/07/20 15:04:50 (permalink)
0

PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V

Hi,
I am using this 64-pin QFP PIC32MM0256GPM064, a lot is set up using MCC.
 
ADC is needed on 12 channels and it is the exact same circuit driving each channel, an amplifier feeding the ADC. 11 channels work correctly. The problem is I have already manufactured the boards as in testing everything seemed fine. So I cannot just use another pin.
 
Issue is the voltage on pin 19 of this device (AN12/C2IND/T2CK/T2G/RC0) does not rise above ~0.8V. It otherwise functions correctly. I need to measure up to 1.2V.
 
It is consistent across multiple chips.
 
I have tried:
  • Disabling CMP2
  • Disabling TMR2 (and gate and clock source set to PBCLK)
  • Checked it is set at INPUT in TRISC and analogue in ANSA12 (    TRISC = 0x0B63;       ANSELA = 0x384C; )
Any ideas welcome thank you!
#1

11 Replies Related Threads

    cvm
    Super Member
    • Total Posts : 293
    • Reward points : 0
    • Joined: 2011/09/16 05:16:15
    • Location: 0
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/20 22:40:12 (permalink)
    0
    ANSELA = 0x384C;
     
    AN12 is on RC0, so ANSELC bit 0 is what you are after.
    Probably doesn't explain your problem though, as ANSELC default value is 0x123 (all pins on port c set to analog). But maybe you are mixing up AN numbers and R numbers in other places also, which may lead to some strange results.
    #2
    jc999
    Starting Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2017/10/08 07:23:13
    • Location: 0
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/20 23:58:31 (permalink)
    0
    Hi,
    Yes sorry I checked and
    TRISA = 0xFB6C;
    TRISB = 0xA4BE;
    TRISC = 0x0B63;
    TRISD = 0x0017;
    ANSELA = 0x384C;
    ANSELB = 0x801E;
    ANSELC = 0x0123;
     
    I read from the buffer periodically, the same as all other 11 channels
    if(ADC1BUF12 > ADC_CHANNEL_VAL)
     
    It is strange as the physical measurement will not go >0.8V as if there is some PPS problem like you say. But the code is MCC generated and all other channels work. I cannot seem to see the problem. I searched and "TRISC" is only used elsewhere as a digital pin for RC10.
     
    Please note I am using this in free-scan / free-running mode so I do not use these registers in the code at all once set up.
     
    Thanks
    JC
    #3
    cvm
    Super Member
    • Total Posts : 293
    • Reward points : 0
    • Joined: 2011/09/16 05:16:15
    • Location: 0
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/21 01:57:24 (permalink)
    0
    Maybe the AN12 CSS bit not set?
     
    Also a note in the PIC32 adc FRM for scan mode (not auto-scan)-
    If the number of scanned inputs selected is greater than the number of samples
    taken per interrupt (defined by the SMPI<4:0> bits), the higher numbered inputs will
    not be sampled.
     
    Maybe SMPI set to 12 instead of 13? But maybe you are using auto-scan which does not use SMPI ('free-scan / free-running mode' - could mean either 'scan' or 'auto-scan' and they are different).
     
    Create a simple test/function/project/whatever to do a basic adc read of an12 (as simple as possible- no scan, buffer in fifo mode where you read buf0, etc). If you can get something good with that, then you seem to have a software problem. If still no good, maybe lift the pin from the pad or isolate the pin some other way so you can play around with it while nothing else is affecting it.
     
    >as if there is some PPS problem
     
    That pin has no pps, so you are left with the 3 other pin functions which you said are not enabled. You could use the debugger to verify I guess.
    #4
    maxruben
    Super Member
    • Total Posts : 3367
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/21 03:18:33 (permalink)
    0
    Disconnect the input amplifier from the pin (cut the trace on the pcb if necessary). Is the voltage still not what you expect?
    Is the amplifier driving high current into the pin (more than a couple of mA) when it is connected to AN12?
     
    /Ruben
     
     
    #5
    jc999
    Starting Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2017/10/08 07:23:13
    • Location: 0
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/21 08:31:22 (permalink)
    0
    Hi, I am not sure of the terminology as it seems to be different everywhere I look. I am using the ADC in auto RUN mode, with channel scanning. It works, sampling all channels selected including this faulty channel. Only this channel pin will not allow >0.8V
     
    Thank you for the suggestions I just checked:
       AD1CSS = 0xFB0F8; // 12 is enabled
       AD1CON2 = 0xC30; // Every 13th sample. Also I am using many higher number ADC channels (AN16, AN17 etc.)
       SMPI set to 13 has no change
       Disabling TMR2 and CMP2 - the switches and comparator stop working. Checked in debugger. Still no fix. Also CMP2 is set to Non Inverting : Internal Reference, Inverting : CINCC, Internal Reference: CDAC1
     
    I lifted the pad. The amplifier output is then correct. It is also the exact circuit repeated multiple times with multiple of these same PICs. 11 of the 12 ADC inputs work correctly, just AN12 has this issue.

    It is like something in the chip is limiting to 0.8V. I do not have the instrumentation to measure the current going into this pin accurately.
     
    The trace goes nowhere else, just from the amplifier to the PIC. Maybe I could try adding an inline current limit resistor but don't see why this should be needed, or why all other channels work
     
     
    Thanks
    #6
    Antipodean
    Super Member
    • Total Posts : 1767
    • Reward points : 0
    • Joined: 2008/12/09 10:19:08
    • Location: Didcot, United Kingdom
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/21 09:05:18 (permalink)
    0
    So you have one of the following (in decreasing order of liklihood)
     
    A solder splash between that pin and some other pin that is clamping the output.
     
    An error in your PCB creating a short to somewhere it shouldn't connect to.
     
    A faulty PCB (not unknown, a colleague had a PCB with shorts between VDD and Vss because he hadn't allowed enough clearance around vias in the PCB master and the manufacturer couldn't work to the fine gaps).
     
    I would lift the IC pins at both ends of the track and then use a multimeter to see where else the track connects.
     
     
     

    Do not use my alias in your message body when replying, your message will disappear ...

    Alan
    #7
    jc999
    Starting Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2017/10/08 07:23:13
    • Location: 0
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/21 11:48:36 (permalink)
    0
    No. I have multiple pcbs all with this issue. It is not soldering. And the circuit is an exact copy over and over 20 times. This fault is only on one analogue channel. It is not luck that this happens on each one. They are assembled by machine. The chances of multiple failure like this must be one in a million.

    The same amps work in the same configuration when connected to a different input as tested just now.

    Then I have taken a meter and put the probe on the trace. There are no vias. Brushing over all the pads, there are no shorts!

    Its odd, I can't figure out the significance of 0.8V cap, when the adc actually works fine up to this
    #8
    cvm
    Super Member
    • Total Posts : 293
    • Reward points : 0
    • Joined: 2011/09/16 05:16:15
    • Location: 0
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/21 12:54:07 (permalink)
    0
    Leave the pad lifted, run a simple program to get the adc value of an12 (as simple as possible- you don't even have to setup the pin as its analog on reset)- simply output the value in a loop if you have a uart or use the debugger with a breakpoint after the adc read to check the value. Put some voltages on the pin to see what you get.
     
    On a pic32mm curiosity board, I just created a simple loop-
    int main(){
        Pins an12{Pins::AN12}; //an12- analog (default)
        for(;;){
            volatile uint16_t v = an12.adcval(); //breakpoint here
            (void)v; //prevent unused variable error
        }
    }
     
    my pin adcval function is simply-
     
    auto Pins::
    adcval () -> uint16_t
    {
    Adc adc;
    adc.mode_12bit(true); //12bit mode
    adc.format(adc.INT16); //integer
    adc.trig_sel(adc.AUTO); //adc starts conversion
    adc.samp_time(31); //max sampling time- 31Tad
    adc.conv_time(); //if no arg,default is 4 (for 24MHz)
    adc.ch_sel((Adc::CH0SA)m_an); //ANn (AVss if no ANn for pin) //m_an in AN12
    adc.on(true);
    adc.samp(true);
    while(not Adc::done()); //blocking
    adc.on(false);
    return (uint16_t)Adc::read(); //default read is from BUF0
    }
     
    I'm sure can easily be translated to C, or maybe MCC can produce the code. That adc function is all you need as the pin is already analog.
     
    Simple run the debugger, watch the variable v. Connect pin to ground, 3v3, and whatever else in between. On my curiosity board I jumped an12 to ground, got 0, to 3v3 got 4095, connected to an14 (on board pot) and could get everything in between.
    #9
    Antipodean
    Super Member
    • Total Posts : 1767
    • Reward points : 0
    • Joined: 2008/12/09 10:19:08
    • Location: Didcot, United Kingdom
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/21 13:26:27 (permalink)
    0
    jc999
    Then I have taken a meter and put the probe on the trace. There are no vias. Brushing over all the pads, there are no shorts!

    Its odd, I can't figure out the significance of 0.8V cap, when the adc actually works fine up to this



    No shorts to where?
     
    At this stage, you have multiple PCBs all with the same fault on the same pin, so I would still suggest you have a PCB manufacturing fault - a hair on the machine printing the etch mask perhaps leaving an extremely thin trace to an adjacent track(s). I would take a spare unpopulated PCB (what do you mean you don't buy spares!) and get a power supply capable of an amp or more, connect one side to the track in question, and then probe the other power supply connection around all the adjacent tracks, and see if you get a fuse action from a fine trace somewhere.
     
    I assume you have solder resist, so it could be difficult to see a hairline trace that would do this sort of thing.
     
     

    Do not use my alias in your message body when replying, your message will disappear ...

    Alan
    #10
    maxruben
    Super Member
    • Total Posts : 3367
    • Reward points : 0
    • Joined: 2011/02/22 03:35:11
    • Location: Sweden
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/22 05:08:43 (permalink)
    0
    Make sure that CNPDC bit 0 (pin 19, RC0/AN12) is 0.
    Otherwise weak pull down on pin 19 would be enabled and it could result in what you get depending on the output impedance of your external amplifier. According to the datasheet it doesn't look like the Change notification bit for this pin have to be enabled for this to happen. And the datasheet doesn't say anything about analog inputs or TRIS registers together with the weak pull up function.
    The same goes for the bits in the ODCC (open drain) register. At least if I read the datasheet correctly.
     
    /Ruben
    #11
    cvm
    Super Member
    • Total Posts : 293
    • Reward points : 0
    • Joined: 2011/09/16 05:16:15
    • Location: 0
    • Status: offline
    Re: PIC32MM0256GPM064 ADC fault (AN12), pin will not go >0.8V 2019/07/22 07:47:31 (permalink)
    0
    According to the datasheet it doesn't look like the Change notification bit for this pin have to be enabled for this to happen. And the datasheet doesn't say anything about analog inputs or TRIS registers together with the weak pull up function.
    The pullup, pulldown and open drain settings are all independent. The pullup/down are in the 300ua range at 3v3, so roughly 10k as a round figure.
     
    #12
    Jump to:
    © 2019 APG vNext Commercial Version 4.5