• AVR Freaks

Hot!Debugging with ICD3/ICD4 on same device sometimes doesn't work

Author
BEsmart
Starting Member
  • Total Posts : 37
  • Reward points : 0
  • Joined: 2019/04/26 06:47:36
  • Location: 0
  • Status: offline
2019/10/16 11:23:04 (permalink)
0

Debugging with ICD3/ICD4 on same device sometimes doesn't work

...I know there are many threads about this, but this behavior seems different.

Trying to start a debugging session with ICD4 (also tried with ICD3) on a PIC18LF46K42 lead to this error message:

***********************************
Erasing...

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0xff
program memory: start address = 0x1000, end address = 0x507f
configuration memory
EEData memory
User Id Memory

Script GetVersionDE failed with status Type = runScript, Script name = GetVersionDE, Status = 0xa00
.
The target device is not ready for debugging. Please check your configuration bit settings and program the device before proceeding. The most common causes for this failure are oscillator and/or PGC/PGD settings.
***********************************

...unfortunately I can't remember what I did to make it work, but it did before on a different of exactly the same device (I build some).
I then first had the same problems an error message comming up but I tried it some times an then it did work!

...btw., where can I change the the PGC/PGD settings for this PIC?
 
Any ideas what went wrong or how to fix this?
Many thanks!!

Here are my configuration bits:
// PIC18LF46K42 Configuration Bit Settings

// 'C' source line config statements

// CONFIG1L
#pragma config FEXTOSC = OFF // External Oscillator Selection (Oscillator not enabled)
#pragma config RSTOSC = HFINTOSC_1MHZ// Reset Oscillator Selection (HFINTOSC with HFFRQ = 4 MHz and CDIV = 4:1)

// CONFIG1H
#pragma config CLKOUTEN = OFF // Clock out Enable bit (CLKOUT function is disabled)
#pragma config PR1WAY = ON // PRLOCKED One-Way Set Enable bit (PRLOCK bit can be cleared and set only once)
#pragma config CSWEN = ON // Clock Switch Enable bit (Writing to NOSC and NDIV is allowed)
#pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor enabled)

// CONFIG2L
#pragma config MCLRE = EXTMCLR // MCLR Enable bit (If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR )
#pragma config PWRTS = PWRT_OFF // Power-up timer selection bits (PWRT is disabled)
#pragma config MVECEN = ON // Multi-vector enable bit (Multi-vector enabled, Vector table used for interrupts)
#pragma config IVT1WAY = ON // IVTLOCK bit One-way set enable bit (IVTLOCK bit can be cleared and set only once)
#pragma config LPBOREN = OFF // Low Power BOR Enable bit (ULPBOR disabled)
#pragma config BOREN = SBORDIS // Brown-out Reset Enable bits (Brown-out Reset enabled , SBOREN bit is ignored)

// CONFIG2H
#pragma config BORV = VBOR_190 // Brown-out Reset Voltage Selection bits (Brown-out Reset Voltage (VBOR) set to 1.90V)
#pragma config ZCD = OFF // ZCD Disable bit (ZCD disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON)
#pragma config PPS1WAY = ON // PPSLOCK bit One-Way Set Enable bit (PPSLOCK bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle)
#pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit (Stack full/underflow will cause Reset)
#pragma config DEBUG = OFF // Debugger Enable bit (Background debugger disabled)
#pragma config XINST = OFF // Extended Instruction Set Enable bit (Extended Instruction Set and Indexed Addressing Mode disabled)

// CONFIG3L
#pragma config WDTCPS = WDTCPS_0// WDT Period selection bits (Divider ratio 1:32)
#pragma config WDTE = SWDTEN // WDT operating mode (WDT enabled/disabled by SWDTEN bit)

// CONFIG3H
#pragma config WDTCWS = WDTCWS_7// WDT Window Select bits (window always open (100%); software control; keyed access not required)
#pragma config WDTCCS = LFINTOSC// WDT input clock selector (WDT reference clock is the 31.0 kHz LFINTOSC)

// CONFIG4L
#pragma config BBSIZE = BBSIZE_512// Boot Block Size selection bits (Boot Block size is 512 words)
#pragma config BBEN = OFF // Boot Block enable bit (Boot block disabled)
#pragma config SAFEN = OFF // Storage Area Flash enable bit (SAF disabled)
#pragma config WRTAPP = OFF // Application Block write protection bit (Application Block not write protected)

// CONFIG4H
#pragma config WRTB = OFF // Configuration Register Write Protection bit (Configuration registers (300000-30000Bh) not write-protected)
#pragma config WRTC = OFF // Boot Block Write Protection bit (Boot Block (000000-0007FFh) not write-protected)
#pragma config WRTD = OFF // Data EEPROM Write Protection bit (Data EEPROM not write-protected)
#pragma config WRTSAF = OFF // SAF Write protection bit (SAF not Write Protected)
#pragma config LVP = OFF // Low Voltage Programming Enable bit (HV on MCLR/VPP must be used for programming)

// CONFIG5L
#pragma config CP = OFF // PFM and Data EEPROM Code Protection bit (PFM and Data EEPROM code protection disabled)

// CONFIG5H

// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.

#include <xc.h>

#1

11 Replies Related Threads

    NorthGuy
    Super Member
    • Total Posts : 5735
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/16 12:08:46 (permalink)
    0
    There's no PGC/PGD settings for this PIC. This might be something connected on RB6/RB7 interfering with the debugger. Otherwise, this may be a bug and should be reported to Microchip.
    #2
    Ian.M
    Super Member
    • Total Posts : 13264
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/16 14:04:41 (permalink)
    0
    Its clearly failing the initial handshake between the debug tool and the debug executive that's supposed to be running on the target.
     
    BEsmart
    // CONFIG2H
    // <snip>
    #pragma config DEBUG = OFF // Debugger Enable bit (Background debugger disabled)

    Really ?? !!!
     
    .... and you wonder why it wont debug! ;)
     
    Remove all reference to the CONFIG2H:DEBUG bit from your code and let the IDE manage it for you.
     
    Also, I notice BOR is enabled.  Try disabling it.
     
    Hopefully there aren't any other issues.
    post edited by Ian.M - 2019/10/16 14:10:33

    --
    NEW USERS: Posting images, links and code - workaround for restrictions.
    I also support http://picforum.ric323.com because this forum is sometimes too broken to use!
    #3
    ric
    Super Member
    • Total Posts : 24217
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/16 14:46:58 (permalink)
    0
    Good point Ian, but I think the tool over-rides whatever you try to set for the DEBUG bit.
    (It also overrides any WDT setting in debug mode).
    BOR is a possibility though.
    If just the ICD4 did it, I'd certainly suggest a firmware bug, but not if the ICD3 does it too.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    BEsmart
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2019/04/26 06:47:36
    • Location: 0
    • Status: offline
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/16 15:32:00 (permalink)
    0
    #pragma config DEBUG = ON  
    #pragma config WDTCPS = WDTCPS_0    

    ... unfortunately doesn't change a thing.
    I've again tried it both with ICD3 and ICD4.
    No luck....
    #5
    ric
    Super Member
    • Total Posts : 24217
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/16 15:35:01 (permalink)
    0
    BEsmart
    ... unfortunately doesn't change a thing.

    As I predicted.
    Don't try to set the DEBUG bit yourself, leave that line out altogether, as it doesn't do anything useful.
    The WDT setting is forced off when the debugger is active, so you can use whatever you want.
    Did you try disabling BOR as Ian suggested?
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #6
    BEsmart
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2019/04/26 06:47:36
    • Location: 0
    • Status: offline
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/16 15:36:13 (permalink)
    0
    #pragma config BOREN = OFF
     
    ...doesn't change a thing, too. :-(
    #7
    NorthGuy
    Super Member
    • Total Posts : 5735
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/16 16:13:33 (permalink)
    +2 (2)
    Would you tell us if something external is connected to PGC/PGD?
    #8
    Ian.M
    Super Member
    • Total Posts : 13264
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/17 00:01:39 (permalink)
    +1 (1)
    ..... or to /MCLR other than a simple 10K pullup to VDD?
     
    The debug executive is code in the PIC, so it must be able to run code stably for debugging to work.  Does a simple 'blinking LED' test program run OK, with the flash rate you expect?  Does the PIC have a stable and adequately decoupled VDD supply?

    --
    NEW USERS: Posting images, links and code - workaround for restrictions.
    I also support http://picforum.ric323.com because this forum is sometimes too broken to use!
    #9
    BEsmart
    Starting Member
    • Total Posts : 37
    • Reward points : 0
    • Joined: 2019/04/26 06:47:36
    • Location: 0
    • Status: offline
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/17 05:40:28 (permalink)
    0
    ...very good clue!

    I have a breakout-board for signal-analyzing connected, which has a 22k pullup on the PGC line for a level translator.
    Disconnecting it, now debugging works fine!

    Debugging seems to be much more sensitive, than programming...

    Many thanks for all your support!
    #10
    Ian.M
    Super Member
    • Total Posts : 13264
    • Reward points : 0
    • Joined: 2009/07/23 07:02:40
    • Location: UK
    • Status: offline
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/17 06:04:19 (permalink)
    0
    Yes.  When debugging the debugger needs pulldowns* on PGC and PGD to keep them in a known state, and prevent glitches during transitions between the debugger driving the line and the target (debug executive) driving the line, so your pullup raised that level to perilously close to the logic '0' threshold.   Its more tolerant during ICSP because the programmer actively drives PGC all the time, and when it hands over PGD to the target for data readback, there's a *LOT* less 'going on' in the target as all other I/O and peripherals are disabled in ICSP mode, so the noise level is lower.  I'd still avoid putting pullups or loads between the pin and Vdd on the ICSP PGC and PGSD pins . . . .
     
    * IIRC Microchip tends to use 4.7K pulldowns in the programmer/debugger, but my knowledge is out of date re: recent tools.  Back in the old old days (Black button PICkit 2 era), it was your responsibility to add pulldowns to the target board you wanted to debug!  

    --
    NEW USERS: Posting images, links and code - workaround for restrictions.
    I also support http://picforum.ric323.com because this forum is sometimes too broken to use!
    #11
    du00000001
    Just Some Member
    • Total Posts : 3161
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: Debugging with ICD3/ICD4 on same device sometimes doesn't work 2019/10/17 06:14:58 (permalink)
    0
    BEsmart
    Debugging seems to be much more sensitive, than programming...

    You're really funny!
     
    During programming, the µC's firmware has no interfering activity. During debugging, PGC and PGD should be reserved to the debugger connection. OR the debugger connection should be able to override the application's signal (somewhat influencing the application - usually not to the better).

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #12
    Jump to:
    © 2019 APG vNext Commercial Version 4.5