• AVR Freaks

Hot!device is not ready for debugging dspic33EP512GP502

Author
Denge
Super Member
  • Total Posts : 91
  • Reward points : 0
  • Joined: 2016/03/03 07:23:12
  • Location: belgium
  • Status: offline
2019/11/27 06:49:16 (permalink)
0

device is not ready for debugging dspic33EP512GP502

Hi All,
 
It is for a few days now I can't get rid of te following error:
Programming/Verify complete
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.

 
The hardware looks correct and the PGD is on pin 4 and PGC on pin 5, so on PGEC3 and PGED3 f the chip.
 
I checked and rechecked the config setting and the oscillator setup, but I can't find what's wrong.
The error says "Programming/Verify complete", so I suppose the PGC/PGD settings and hardware is correct.
 
Here the config code
.text ; Program memory
;------------------------------------------------------------------------------
; Configuration 
;------------------------------------------------------------------------------
; Communicate on PGEC3 and PGED3,
; JTAG is disabled
; Clock switch to PLL source will wait until the PLL lock signal is valid,
; Watchdog timer enabled/disabled by user software,
; OSC2 is general purpose digital I/O pin,
; Internal Fast RC (FRC)
; Start up with user-selected oscillator source
; Allow multiple reconfiguration
; Clock switching is enabled,Fail-safe Clock Monitor is disabled
; Primary Oscillator disabled
    .section __CONFIG_REG.sec, code
    .global __CONFIG_REG
__CONFIG_REG: .pword ICS_PGD3 & JTAGEN_OFF & PLLKEN_ON & FWDTEN_OFF & OSCIOFNC_ON & FNOSC_FRC & IESO_OFF & IOL1WAY_OFF & FCKSM_CSECMD & POSCMD_NONE & GCP_OFF

;------------------------------------------------------------------------------

and here the oscillator setup
;------------------------------------------------------------------------------
.text
; Oscillator setup
initOsc:

; Configure PLL prescaler, PLL postscaler, PLL divisor
; for 119,15 MHz or ~60 MIPS
    mov #95,w0 ; M=97
    mov w0,PLLFBD
    
    bclr CLKDIV,#PLLPOST0 ; N2=2
    bclr CLKDIV,#PLLPOST1 ;
    bset CLKDIV,#PLLPRE0 ; N1=3
    
; Initiate Clock Switch to FRC oscillator with PLL (NOSC=0b001)
    mov.b #1,w3 ; Fast RC Oscillator with PLL
    mov #0x78, w0
    mov #0x9A, w1
    mov #_OSCCON+1, w2
    mov.b w0, [w2]
    mov.b w1, [w2]
    mov.b w3, [w2]
    
    mov #0x46, w0
    mov #0x57, w1
    mov #_OSCCON, w2
    mov.b w0, [w2]
    mov.b w1, [w2]
    mov.b w3, [w2]
    
; Wait for Clock switch to occur
0:
    btss OSCCON,#COSC0
    bra 0b
    
; Wait for PLL to lock
1:
    btss OSCCON,#LOCK
    bra 1b
    
    return

 
dspic33EP512GP502

MPLAB X IDE v5.25
XC16 V1.41
 
Thanks for helping!
 
 
#1

13 Replies Related Threads

    Mysil
    Super Member
    • Total Posts : 3482
    • Reward points : 0
    • Joined: 2012/07/01 04:19:50
    • Location: Norway
    • Status: online
    Re: device is not ready for debugging dspic33EP512GP502 2019/11/27 07:45:26 (permalink)
    0
    Hi,
    I have seen similar messages occasionally,mostly with PKOB debugging tool.
    This may happen, also when the same device and debugger setup, have been successfully debugged or run just before.
    If there is nothing else wrong, just doing a Reset of the target, Round Blue button in the toolbar, may work.
     
    Be aware that  MPLAB  will be able to Program and Verify the flash, even if oscillator do not work,
    or if there may be a mistake in config bits.
     
    For Debugging to be possible, the selected oscillator must run, and debugger pin selection in configuration bits must be correct
    #2
    du00000001
    Just Some Member
    • Total Posts : 3238
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/11/27 08:43:59 (permalink)
    0
    Does a simple test program (e.g. toggling a single pin) with the same config settings run ?

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #3
    Denge
    Super Member
    • Total Posts : 91
    • Reward points : 0
    • Joined: 2016/03/03 07:23:12
    • Location: belgium
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/11/27 09:18:34 (permalink)
    0
    Hi du0000001,
     
    I didn't try this, but as Mysil is pointing to the oscillator which is a good guess I think.
    On the other hand, I've been turning the oscillator setup upside down and inside out and I can't see what I did wrong in this code.
    #4
    du00000001
    Just Some Member
    • Total Posts : 3238
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/11/27 09:52:42 (permalink)
    0
    The "simple test program" is intended to check whether the oscillator is working at all - - - resp. working as expected.
    Nothing more ...  Smile
     
    You could as well use MCC to get a (usually) working oscillator configuration (plus all the CONFIG bits).
    If you use a separate project just for MCC configuration purposes, there is no need to take over all the fancy mcc_generated files - just copy what you most urgently need.

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #5
    Denge
    Super Member
    • Total Posts : 91
    • Reward points : 0
    • Joined: 2016/03/03 07:23:12
    • Location: belgium
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/11/27 10:02:05 (permalink)
    0
    I'll give this a shot tomorrow morning.
    Thanks for the idea.
    #6
    Aussie Susan
    Super Member
    • Total Posts : 3637
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/11/27 17:56:41 (permalink)
    4.5 (2)
    You can always program an MCU as that does not require a working oscillator.
    However to debug your code does require a working oscillator of some sort - hence why @du00000001 is asking you to try a trivial test program.
    The way debugging works is that, when you do a debug build, a 'debug kernel' is added to your program and this is the first bit of code that executes after a reset. The kernel uses the ICS_PDGx setting to know which pair of programming pins to use (you can program with any pair but you must specify the correct pair to debug). It tries to communicate with the IDE and will not go further until it establishes communication. Of course, to execute the kernel code, an oscillator of some sort must be running.
    For its part, the IDE will try to talk to the kernel code. If it can't for whatever reason, then that is when you get the message.
    Susan
    #7
    Denge
    Super Member
    • Total Posts : 91
    • Reward points : 0
    • Joined: 2016/03/03 07:23:12
    • Location: belgium
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/12/02 10:32:51 (permalink)
    0
    Hi du0000001 and Susan,
    I followed the advice of du0000001 and configured with MCC a very simple project.  This compiled without errors and I was able to single step it.  However, my knowledge of C is very low, so I didn't make something useful with it.
    I copied the setting  to my project and also compared the MCC disassembly to my code.
    Then I stripped down my code as far as possible and excluded all files except the main.
    And it stays complaining that the target device is not ready for debugging.
    I added the full project (replace .txt by .zip) as I don't know where to look anymore.
    Thanks
    #8
    du00000001
    Just Some Member
    • Total Posts : 3238
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/12/02 11:28:55 (permalink)
    0
    OK - we now know your hardware is basically operational.
    It's just that your current oscillator configuration has nothing to do with the configuration with which the issues occurred.
     
    Now try to upgrade your test version to the oscillator configuration you want to achieve (in terms of MIPS - not necessarily in terms of exact register values) ...

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #9
    Denge
    Super Member
    • Total Posts : 91
    • Reward points : 0
    • Joined: 2016/03/03 07:23:12
    • Location: belgium
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/12/02 13:04:59 (permalink)
    0
    Hi du0000001,
    I'm agree with you the hardware on communication is operational. But that's what's puzzling me. What you suggest goes out from the permission the oscillator is running and is executing the code to configure the oscillator.  But that far I even can't get!  So it looks like the internal oscillator (FRC) is not starting at all although I configured it to run without PLL (in the first stage).
    #10
    du00000001
    Just Some Member
    • Total Posts : 3238
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/12/02 13:34:43 (permalink)
    5 (1)
    It might be a wrong assuption that the debugger doesn't start, as it usually starts automatically post programming. Then it could get stuck due to the change in clock configuration.
     
    You can try it the other way round: use your original application and just comment out the change in the clock configuration. If debugging is possible then . . . you know where to look at  :)

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #11
    Denge
    Super Member
    • Total Posts : 91
    • Reward points : 0
    • Joined: 2016/03/03 07:23:12
    • Location: belgium
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/12/04 03:34:10 (permalink)
    0
    Hi,
     
    I got my (stupid) error!  But now I ran into another I still don't understand.
    #12
    ric
    Super Member
    • Total Posts : 24608
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: device is not ready for debugging dspic33EP512GP502 2019/12/04 04:25:33 (permalink)
    0
    Denge
    I got my (stupid) error!

    Which was what?
     

    But now I ran into another I still don't understand.

    We can't help if you don't mention what the new problem is.

    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!
    #13
    Denge
    Super Member
    • Total Posts : 91
    • Reward points : 0
    • Joined: 2016/03/03 07:23:12
    • Location: belgium
    • Status: offline
    Re: device is not ready for debugging dspic33EP512GP502 2019/12/04 04:33:18 (permalink)
    0
    Hi,
     
    A little a shame as I interpreted the config syntax completely wrong:
        .section __CONFIG_REG.sec, code
        .global __CONFIG_REG
    __CONFIG_REG: .pword ICS_PGD3 & JTAGEN_OFF & PLLKEN_ON & FWDTEN_OFF & OSCIOFNC_ON & FNOSC_FRC & IESO_OFF & IOL1WAY_OFF & FCKSM_CSECMD & POSCMD_NONE & GCP_OFF

    to this
    ; Communicate on PGEC3 and PGED3, JTAG is disabled
    .section __FICD.sec, code
    .global __FICD
    __FICD: .pword ICS_PGD3 & JTAGEN_OFF
     
    ; Clock switch to PLL source will wait until the PLL lock signal is valid,
    ; Watchdog Timer in Non-Window mode
    ; Watchdog timer enabled/disabled by user software
    .section __FWDT.sec, code
    .global __FWDT
    __FWDT: .pword PLLKEN_ON & WINDIS_OFF & FWDTEN_OFF
     
    ; Primary Oscillator disabled
    ; OSC2 is general purpose digital I/O pin
    ; Allow multiple reconfigurations
    ; Both Clock switching and Fail-safe Clock Monitor are enabled
    .section __FOSC.sec, code
    .global __FOSC
    __FOSC: .pword POSCMD_NONE & OSCIOFNC_ON & IOL1WAY_OFF & FCKSM_CSECME
     
    ; Internal Fast RC (FRC)
    ; Start up with user-selected oscillator source
    .section __FOSCSEL.sec, code
    .global __FOSCSEL
    __FOSCSEL: .pword IESO_OFF & FNOSC_FRCPLL

    ; General Segment may be written
    ; General Segment Code protect is Disabled
    .section __FGS.sec, code
    .global __FGS
    __FGS: .pword GWRP_OFF & GCP_OFF
         
         

    solved the starting problem.
     
    For the other error I'll start a new thread
     
    #14
    Jump to:
    © 2019 APG vNext Commercial Version 4.5