0

My board can be started with a blank pic and programmed through ICSP without problems but while running, the start of a programming session may lead to dangerous behavior.

How can I detect the start of a programming cycle and execute some code to safe the hardware?

pickit123
  • 1
  • 1
  • I don't believe there is a way to do this in firmware. ICSP on PIC18 starts by holding the programming data and clock lines low, raising MCLR to VIHH, and resetting the PIC. This places the PC at address 0 where it is then issued a command on the ICSP data and clock lines. Concerns over hardware safety during programming should be addressed in hardware (I.E. pull-up/pull-down resistors on lines that must be held in a "safe" state during programming) See http://ww1.microchip.com/downloads/en/devicedoc/31028a.pdf for more info on ICSP on PIC18 – K_Trenholm Feb 06 '19 at 17:06

1 Answers1

0

Your question is open to interpretation. By this I mean that when observed in operation the Microchip device programming tools appear to allow the users code to run during the programming operation. For the PIC18 family of parts this is not the case.

The Microchip device programming application causes the PIC18 to go through reset several time before the flash update begins. User code will run after each of the resets, but for how long depends on Microchip device programming application.

The most effective solution I've found comes in two parts:

  1. Design the hardware to power up in a safe state when the PIC18 device is blank or not present.
  2. Wait from 0.5 seconds to 3.5 seconds after Power-On-Reset before setting any GPIO pins as outputs.

The second part may not be possible in all applications but it does make using the MPLAB debugger more reliable.

Dan1138
  • 1,150
  • 8
  • 11