I have the same issue with programming a PIC24FJ256GA406 with PicKit4 and ICD4. In Low program mode I can get the same failure:
Verify failed. [ Pgm ] at 0x15794, expected 0x00b3c0a3, got 0x00b340a3
Programming did not complete.
I have VCAP connected to 10uF cap to gnd and VBAT is pulled up to 3.3v with 1.5k.
Any suggestions would be greatly appreciated.
Yours is far more complicated.
This is a dual partition chip.
If the chip is partitioned, 0x15794 is the address of the FSIGN configuration word. When the chip is programmed the flash controller clears bit 15 of FSIGN. Now, if you try to write to this location, bit 15 will remain clear.
Your program doesn't seem to be partitioned, some of your code is written to 0x15794 (you have a big program if it reaches that far). This fail because bit 15 is zero. Looks like the programmer partitioned the PIC while you really didn't want that.
1. Look at your project and make sure that FBOOT configuration word is set correctly to a single partiton mode
#pragma BTMODE = 0x3
or BTMODE is not set at all
If this doesn't help
2. You can try to erase the chip then reboot and start over. Erasing removes partitioning.
If this doesn't help
3. Perhaps there's a bug in tools which results in incorrect partitioning. Updating to newer version, as well as updating firmware in your programmers may help.