AnsweredHot!Can program and run but can't debug when switching from USB SK2 to USB SK3

Author
mpr95
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2015/09/01 09:03:30
  • Location: 0
  • Status: offline
2018/07/11 14:14:18 (permalink)
0

Can program and run but can't debug when switching from USB SK2 to USB SK3

Hello,
 
I get the msg
"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."
I'm can't debug a simple blink program on USB SK3,  Mplabx 4.20 with XC32 V1.40. I tried using the config bits source code below.  I'm trying to figure out what the oscillator settings should be. Does Y2 need to be loaded to debug?
 
Thanks 
 
// PIC32MX470F512L Configuration Bit Settings
// 'C' source line config statements
// DEVCFG3
// USERID = No Setting
#pragma config FSRSSEL = PRIORITY_7 // Shadow Register Set Priority Select (SRS Priority 7)
#pragma config PMDL1WAY = ON // Peripheral Module Disable Configuration (Allow only one reconfiguration)
#pragma config IOL1WAY = ON // Peripheral Pin Select Configuration (Allow only one reconfiguration)
#pragma config FUSBIDIO = ON // USB USID Selection (Controlled by the USB Module)
#pragma config FVBUSONIO = ON // USB VBUS ON Selection (Controlled by USB Module)
// DEVCFG2
#pragma config FPLLIDIV = DIV_12 // PLL Input Divider (12x Divider)
#pragma config FPLLMUL = MUL_24 // PLL Multiplier (24x Multiplier)
#pragma config UPLLIDIV = DIV_12 // USB PLL Input Divider (12x Divider)
#pragma config UPLLEN = OFF // USB PLL Enable (Disabled and Bypassed)
#pragma config FPLLODIV = DIV_256 // System PLL Output Clock Divider (PLL Divide by 256)
// DEVCFG1
#pragma config FNOSC = FRC // Oscillator Selection Bits (Fast RC Osc (FRC))
#pragma config FSOSCEN = ON // Secondary Oscillator Enable (Enabled)
#pragma config IESO = ON // Internal/External Switch Over (Enabled)
#pragma config POSCMOD = OFF // Primary Oscillator Configuration (Primary osc disabled)
#pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin (Disabled)
#pragma config FPBDIV = DIV_8 // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/8)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled)
#pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler (1:1048576)
#pragma config WINDIS = OFF // Watchdog Timer Window Enable (Watchdog Timer is in Non-Window Mode)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled (SWDTEN Bit Controls))
#pragma config FWDTWINSZ = WINSZ_25 // Watchdog Timer Window Size (Window Size is 25%)
// DEVCFG0
#pragma config DEBUG = OFF // Background Debugger Enable (Debugger is Disabled)
#pragma config JTAGEN = ON // JTAG Enable (JTAG Port Enabled)
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select (Communicate on PGEC1/PGED1)
#pragma config PWP = OFF // Program Flash Write Protect (Disable)
#pragma config BWP = OFF // Boot Flash Write Protect bit (Protection Disabled)
#pragma config CP = OFF // Code Protect (Protection Disabled)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#include <xc.h>
 
#1
RISC
Super Member
  • Total Posts : 5240
  • Reward points : 0
  • Status: online
Re: Can program and run but can't debug when switching from USB SK2 to USB SK3 2018/07/11 15:12:26 (permalink) ☼ Best Answerby mpr95 2018/07/12 07:29:13
5 (1)
Hi,
 
How is your PC connected to the USB SK III :
1/ You use the debug interface from the starter kit (so called "PKOB")
2/ You connect to the starter kit through an external tool ?
 
From the schematics, I noticed that  USB SK III uses the PGC2 and PGD2 ICSP pair.
your settings in configuration bits show PGC1 and PGD1.
You may want to change this setting
 
Regards
 
#2
mpr95
Starting Member
  • Total Posts : 39
  • Reward points : 0
  • Joined: 2015/09/01 09:03:30
  • Location: 0
  • Status: offline
Re: Can program and run but can't debug when switching from USB SK2 to USB SK3 2018/07/12 07:29:37 (permalink)
4.5 (2)
I am connecting the kit to my PC using the PKOB debug USB.  You are right about the the USB SK III using the PGC2 and PGD2 pair. As you pointed out, I had my config set incorrectly as #pragma config ICESEL = ICS_PGx1. I changed it to #pragma config ICESEL = ICS_PGx1 and the debugger is working now. Thank you! 
#3
Jump to:
© 2018 APG vNext Commercial Version 4.5