Attempting low voltage programming (MCLR) on PIC18F24K22 and failing...

geekoftheweek

Joined Oct 6, 2013
550
A little background...

Due to my PICKit2 going up in smoke I thought I would give a try at programming a programmer. I have a PIC18F2550 set up to reprogram itself on the fly along with a few other things besides the latest task of being a programmer.

The 18F2550 is connected up to a PIC18F24K22 and with the help of a home brewed logic analyzer I can see that so far it seems things are working somewhat the way they should. The analyzer is an extremely basic design and only 177 kHz so it may be missing important details, but I'm hoping that is not the issue at the moment...

Following the programming specification (programming spec here) I'm trying to read the device id from the PIC as a way to decide if it is in program mode or not.

The 18F24K22 is fresh out of the box so the low voltage mode is still enabled from the factory. I have 1K resistors between the 18F2550 and the PGD and PGC pins on the 18F24K22 to prevent any short circuits so I know I haven't destroyed anything yet. The MCLR is has a 10K pull up resistor to 5V and it then is pulled low by a NFET controlled by the 18F2550 when needed.

What seems to be happening is the 18F2550 is doing exactly what it is programmed to do so far. It sends the enter low voltage program mode sequence, toggles the MCLR pin when it needs to, and sends commands like it should. The 18F24K22 on the other hand is either is not entering low voltage program mode or not getting what it expects as input and is not responding like it should.

Maybe I just need to stare at the program longer, but thought maybe a fresh set of eyes could spot any problems.

Timer 3 is used to make the clock cycles as even as possible (it probably doesn't matter as far as I can tell, but it helps make it show up on the analyzer), and add delays when needed.

Relevant code:

Code:
movlfa macro literal, reg
movlw literal
movwf reg, a
endm

caseGotoA macro literal, reg, new_pc
movlw literal
xorwf reg, w
btfsc STATUS, Z
goto new_pc
endm

setAndWaitForTimer3 macro literalh, literall
bsf T3CON, RD16
bsf T3CON, TMR3ON
movlfa literalh, TMR3H
movlfa literall, TMR3L
bcf PIR2, TMR3IF
btfss PIR2, TMR3IF
Buena suerte.