• AVR Freaks

Hot!PIC18F25K50 brown-out reset caused by the ADC and FVR

Author
DavidEGrayson
Super Member
  • Total Posts : 108
  • Reward points : 0
  • Joined: 2009/01/08 01:16:58
  • Location: Las Vegas, NV
  • Status: offline
2015/10/14 15:52:07 (permalink)
4 (2)

PIC18F25K50 brown-out reset caused by the ADC and FVR

Hello. I would like to report a problem with the PIC18F25K50 that really seems like a hardware bug. I have simple C code that can reproduce the problem on a 28-pin SPDIP PIC18F25K50. I also saw the problem happening on the 28-pin QFN version.
 
It seems like anyone trying to use the FVR and the ADC would have encountered this issue, but I looked around and didn't see any mention of it. Am I missing something?
 
The problem is that if the ADC's holding capacitor has a high voltage on it (VDD) and then you connect the ADC to the Fixed Voltage Reference (FVR), a brown-out reset occurs. To reproduce this, the FVR should be set to 1.024 V and the brown-out threshold should be 2.85 V. I think that the high voltage on the ADC's capacitor is flowing into the FVR and causing some problem.
 
The code below can be used to reproduce the problem. The comments in it explain exactly how it works and what you should see when you run it:
 
/* Code for the PIC18F25K50 that causes a brown-out reset by dumping a
* high voltage onto the FVR from the ADC's holding capacitor.
*
* Connections:
* RA0: Tie this pin to an LED that turns on when the pin is high.
* RA1/AN1: Don't connect anything to this pin.
* RA2/AN2: Don't connect anything to this pin.
* VDD: Connect a power source between 3 V and 5 V.
* GND: Connect to the GND of the power source.
*
* Expected behavior:
* On power up, LED blinks twice, pauses, then turns on.
*
* Actual behavior:
* On power up, LED blinks twice, pauses, blinks 4 times, pauses,
* blinks 4 times, pauses, blinks 4 times, pauses...
* This indicates that a brownout reset happens when the ADC
* is connected to the FVR.
*/

#pragma config FOSC = INTOSCIO
#pragma config CFGPLLEN = OFF
#pragma config CPUDIV = NOCLKDIV
#pragma config nPWRTEN = ON
#pragma config BOREN = ON
#pragma config BORV = 285
#pragma config nLPBOR = OFF

#define _XTAL_FREQ 1000000

#include <xc.h>

#define LED_ENABLE() (TRISA0 = 0)
#define LED(on) (on ? LATA0 = 1 : LATA0 = 0)

void delay_ms(unsigned int delay)
{
while(delay--) { __delay_ms(1); }
}

void blink()
{
LED(1);
delay_ms(100);
LED(0);
delay_ms(300);
}

void main(void)
{
LED_ENABLE();

/* Make RA1/AN1 be an analog input and drive it high. */
ANSELAbits.ANSA1 = 1;
TRISA1 = 0;
LATA1 = 1;

/* Make RA2/AN2 be an analog input and drive it low. */
ANSELAbits.ANSA2 = 1;
TRISA2 = 0;
LATA2 = 0;

/* Enable the FVR for 1.024 V operation. */
VREFCON0 = 0b10010000;
while(!VREFCON0bits.FVRST) { }

/* Check for a brown-out reset. */
RCONbits_t initialRCON = RCONbits;
RCONbits.POR = 1;
RCONbits.BOR = 1;
if (initialRCON.POR && !initialRCON.BOR)
{
/* A brown-out reset occurred. */
blink();
blink();
}

/* Charge up the ADC's holding capacitor by selecting AN1, which
* is driving high. */
ADCON0 = 0b00000101;

blink();

/* Uncommenting the line below fixes the problem, because it
* allows the ADC's holding capacitor to discharge by selecting
* AN2, which is driving low. */
// ADCON0 = 0b00001001;

blink();

delay_ms(400);

/* Select the FVR, connecting its output to the ADC's holding
* capacitor. This causes a brown-out reset if the capacitor is
* charged. */
ADCON0 = 0b01111101;

while(1)
{
LED(1);
}
}
 
I also posted the code here: https://gist.github.com/DavidEGrayson/8dae6a2afeaffd44f1db.
 
I don't think it matters, but for completeness: I compiled that code with XC8 v1.33 on Windows 8.1, and loaded it onto a PIC using the PICkit 3. The commands I used to compile and load it were:
 
xc8 fvrbor.c -ofvrbor.hex --mode=free --chip=18f25k50
pk3cmd -Ffvrbor.hex -P18f25k50 -M -L
 
I ran the code on a simple protoboard with some wires soldered to it and a socket for the SPDIP PIC18F25K50. My board has a 0.1 uF capacitor between GND and VDD. The problem occurs regardless of whether the PICkit3 is connected to the board. In my original setup with the QFN chip, I was able to see a 100 mV dip on the VDD line that coincided with the reset, but that voltage dip is not happening with the SPDIP chip on the protoboard.
 
Workarounds
 
The only real workaround I know of is to discharge the ADC's holding capacitor by selecting an analog input tied to GND. The code above shows how to do that. This PIC does not have an internal ADC channel that connects to GND, so it means that you need an analog input pin in your design that you can safely drive low. If you wanted to use every single analog input on the PIC and you had no control over their levels, you would not be able to use this workaround.
 
You can also make the problem stop happening by lowering the brown-out threshold from 2.85 V nominal to 2.5 V nominal, and ensuring that VDD is 4.5 V or higher. Of course, this doesn't address the root cause of the problem and it is not good to do it on systems operating at a high speed, so I wouldn't really recommend this as a workaround.
 
Since the ADC discharges its capacitor for two cycles at the end of a conversion, with careful timing it might be possible to switch to the FVR channel in the middle of a conversion and solve the problem that way. I have not tried that.
 
Setting the FVR to a higher voltage like 4.096 V might also help solve the problem, since that would be closer to 5 V. I have not tried that.
 
Does anyone know of a good workaround to this problem that does not require an external pin?
post edited by DavidEGrayson - 2015/10/14 16:38:10
#1

7 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 18033
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: PIC18F25K50 brown-out reset caused by the ADC and FVR 2015/10/14 16:05:47 (permalink)
    0 (1)
    You would have to put in a Support Ticket.
    I do not think I have seen any Microchip H/W guys here.
    It can't be Errata until they confirm it.
     
    #2
    DavidEGrayson
    Super Member
    • Total Posts : 108
    • Reward points : 0
    • Joined: 2009/01/08 01:16:58
    • Location: Las Vegas, NV
    • Status: offline
    Re: PIC18F25K50 brown-out reset caused by the ADC and FVR 2015/10/14 16:18:59 (permalink)
    0
    Thanks, I agree and I just submitted a support ticket.
    #3
    DavidEGrayson
    Super Member
    • Total Posts : 108
    • Reward points : 0
    • Joined: 2009/01/08 01:16:58
    • Location: Las Vegas, NV
    • Status: offline
    Re: PIC18F25K50 brown-out reset caused by the ADC and FVR 2015/10/19 10:44:43 (permalink)
    +5 (3)
    A Microchip representative was able to reproduce my issue on a PIC18F45K50 PDIP chip and has contacted the product owner about it.
    #4
    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re: PIC18F25K50 brown-out reset caused by the ADC and FVR 2015/10/19 10:50:08 (permalink)
    0
    Interesting, thanks!

    GENOVA :D :D ! GODO
    #5
    DavidEGrayson
    Super Member
    • Total Posts : 108
    • Reward points : 0
    • Joined: 2009/01/08 01:16:58
    • Location: Las Vegas, NV
    • Status: offline
    Re: PIC18F25K50 brown-out reset caused by the ADC and FVR 2015/10/23 14:32:43 (permalink)
    +2 (2)
    Currently, I think the best workaround for this problem is to drive an analog input pin low and select it as the ADC input for 10 microseconds.  You can drive it low using the pin's own digital output circuitry; the pin doesn't need to be externally connected to GND.  But if you are using all the analog inputs and can't do that, it seems like you can connect the ADC to the Temperature Diode input for 10 microseconds instead.  This worked for me.  I am trying to find more information about the PIC18F25K50's Temperature Diode so I can make sure this solution will work reliably at different temperatures, but it probably will.
     
    The Microchip representative has not told me about any new workarounds that I can reproduce, but they are still looking in to it.
     
    post edited by DavidEGrayson - 2015/10/23 14:39:20
    #6
    DavidEGrayson
    Super Member
    • Total Posts : 108
    • Reward points : 0
    • Joined: 2009/01/08 01:16:58
    • Location: Las Vegas, NV
    • Status: offline
    Re: PIC18F25K50 brown-out reset caused by the ADC and FVR 2015/10/27 19:34:00 (permalink)
    +2 (2)
    This is a full list of all the workarounds I know of at this point.
     
    1) Select the temperature diode as the ADC input for 10 microseconds.
    2) Drive an analog input pin low and select it as the ADC input for 10 microseconds.
    3) Select the DAC (configured to output 0 V) as the ADC input for some time.
    4) If you can guarantee the output from the CTMU to the ADC will be low, then select that for some time.
    5) Turn the ADC off (ADON = 0) for 1 second.
    6) Take advantage of the fact that the ADC will discharge the capacitor for two cycles at the end of every conversion (requires precise timing of the instruction that changes the ADCON0 CHS bits).
    7) Lower the brown-out threshold and make sure VDD is high enough.
    8) Try setting the FVR to a higher voltage like 4.096 V.  (Not sure if this will work.)
     
    Workarounds #1 through #6 all work the same way: they discharge the ADC's holding capacitor before connecting it to the FVR.  Workarounds #7 and #8 are not very good.  I have tested #1, #2, #5, #6, and #7.  I have not tested #3 and #4 but I expect them to work.  I have not tested #8 and am not sure if it will work.  
    post edited by DavidEGrayson - 2015/10/28 15:30:16
    #7
    jdunne525
    Junior Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2006/04/28 10:54:28
    • Location: 0
    • Status: offline
    Re: PIC18F25K50 brown-out reset caused by the ADC and FVR 2019/11/06 10:54:53 (permalink)
    0
    I realize this is a very old thread, but it was quite helpful for me to resolve a similar issue on a PIC26K40.  
     
    Another option which I utilized was to simply select AVSS (Analog Ground) as the channel input between conversions.  One doesn't need to select this channel for long as its by definition very low impedance.
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5