Professional Documents
Culture Documents
Microchip Debugging Methodology PDF
Microchip Debugging Methodology PDF
METHODOLOGY
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 37
Debugging Methodology
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 38
In-Circuit Serial Programming Interface
Integrated
Development
Environment Programmer Target
+ Debugger Hardware
Language Tool
MPLAB®
REAL ICE
TM
ACTIVE
STATUS
FUNCTION RESET
MPLAB® X IDE
MPLAB REAL ICE™ Your Hardware
In-Circuit Emulator
C language Design
MPLAB ICD 3 or
Compiler(s)
PICkit™ 3 A Microchip
Programmer/Debugger development board
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 39
Connecting the Hardware to the
Programmer/Debugger
Vdd
Vpp/MCLR
PIC® PGC
MCU PGD
Vss
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 40
Communicating with a
Programmer/Debugger
Vdd
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 41
ICSP™ Connectors
Vdd
Vpp/MCLR
PGC
PGD
Vss
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 42
ICSP™ Connectors
Vdd
Vpp/MCLR
PGC
PGD
Vss
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 43
ICSP™ Connectors
Vdd
Vpp/MCLR
PGC
PGD
Vss
Part Number
AC164110
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 44
Elements of a PIC® MCU
Program
Memory
VDD
vpp/MCLR
PIC®
CPU
Microcontroller
PGC
configuration bits
VSS
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 45
Configuration Bits
• Set at program
time the
Configuration Program
Memory
Bits enable VDD
circuitry on the
PIC® MCU vpp/MCLR
CPU
•For example:
A PIC ® MCU PGC
determines It’s configuration bits
settings VSS
Program
Internal Memory
VDD
Debug
Hardware
vpp/MCLR
CPU
PGC
debug configuration bit
VSS
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 48
Internal Debug Hardware
Communicates with MPLAB® X
IDE and Debugger through the
PGD and PGC pins
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 52
Debug Headers
Allows debugging
when:
Not enough pins are
available
Device doesn’t have
debug capability
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 53
Debug Mode Operation
Program
Internal Memory
Debug
VDD
Hardware
vpp/MCLR
CPU
When the code is Debug config. bit
PGC
ready to test the File Registers
user selects PGD
“Debug Main
Project” icon from VSS
the MPLAB® X IDE
toolbar
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 54
Debug Mode Operation
MPLAB® X IDE will
build a image to be
programmed into
the PIC® MCU’s Internal
Program
Memory
Program Memory VDD
Debug
Hardware
This downloadable
image will also
have the debug
configuration bit
enabled
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 55
Debug Mode Operation
vpp/MCLR
MPLAB® CPU
REAL ICE Debug config. bit
TM
ACTIVE
STATUS
PGC
FUNCTION RESET
File Registers
PGD
vpp/MCLR
Debug Executive
MPLAB® CPU
REAL ICE Debug config. bit
TM
ACTIVE
STATUS
PGC
FUNCTION RESET
File Registers
PGD
VSS
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 57
Debug Mode Operation
After programming,
when MCLR is
Program
released all resource Internal Memory
needed for VDD
Debug
Hardware
debugging are User Code
allocated
vpp/MCLR
Debug Executive
MPLAB® CPU
REAL ICE Debug config. bit
TM
ACTIVE
STATUS
PGC
FUNCTION RESET
File Registers
2 HW stack Debug variables
PGD
In debugging mode locations ( 8 bit)
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 58
Production Mode Programming
Program
Internal Memory
Debug
VDD
Hardware
vpp/MCLR
CPU
Debug config. bit
PGC
When the code is ready File Registers
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 59
Production Mode Programming
•MPLAB ®X
IDE will build a Internal
Program
Memory
image to be download VDD
Debug
Hardware
which includes only the
user’s applications code
vpp/MCLR
and no debug executive.
CPU
PGC
File Registers
will have the debug PGD
configuration bit
DISABLED VSS
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 60
Production Mode Programming
vpp/MCLR
MPLAB® CPU
REAL ICE Debug config. bit
TM
ACTIVE
STATUS
PGC
FUNCTION RESET
File Registers
PGD
vpp/MCLR
MPLAB® CPU
REAL ICE Debug config. bit
TM
ACTIVE
STATUS
PGC
FUNCTION RESET
File Registers
PGD
VSS
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 62
Production Mode Programming
• MCLR is released by
programmer/debugger Program
Internal
PIC® MCU exits RESET Debug
Memory
VDD
Hardware
User Code
vpp/MCLR
MPLAB® CPU
REAL ICE Debug config. bit
TM
ACTIVE
STATUS
PGC
FUNCTION RESET
File Registers
PGD
VSS
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 63
Production Mode Programming
Program
Memory
VDD
User Code
vpp/MCLR
MPLAB® CPU
REAL ICE Debug config. bit
TM
ACTIVE
STATUS
PGC
FUNCTION RESET
File Registers
PGD
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 64
Knowledge Check
Question:
TRUE or FALSE it is generally a good idea to
enter a compiler directive to set the debug
configuration bit?
Answer:
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 65
Knowledge Check
Question:
When the Software Simulator is used instead of a
programmer/debugger the developer can expect a
different user interface?
Answer:
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 66
Knowledge Check
Question:
When running in debug mode a PIC® MCU runs at
slightly slower speed than in release more?
Answer:
© 2013 Microchip Technology Incorporated. All Rights Reserved. 17002 DEV Slide 67