PIC programmer plug-in

The PIC programmer plug-in will allow a PIC16F8XX based expansion board that is hooked up to the Homevision controler's I2C bus to be reprogrammed without the need for a hardware PIC programmer. It isn't even necessary to powerdown or disconnect the device or remove the PIC from the device. All that is required is that the PIC is initially programmed with a program containing a self-programming routine. So if you don't have a hardware PIC programmer, you only have to bother a friend once to program it for you. Also some suppliers offer to initially program the PIC for you for a small fee when you buy it. The self-programming routine fits in less than 128 code words, taking up only 6% of the programming space of a PIC16F819 or 3% of a PIC16F88.

The plug-in currently supports the following PIC models:

  • PIC16F87
  • PIC16F88
  • PIC16F818
  • PIC16F819
  • PIC16F872
  • PIC16F873
  • PIC16F873A
  • PIC16F874
  • PIC16F874A
  • PIC16F876
  • PIC16F876A
  • PIC16F877
  • PIC16F877A
As far as I'm aware, those are all PIC16F8XX's with both an I2C interface and the ability to write to flash program memory.

Some of the mentioned PICs require blocks of 32 words to be erased before they can be reprogrammed. Also some PICs must be programmed in blocks of 4 words. This can be observed in the PIC programmer window. Below is an image of what the window might look like while programming a PIC16F819:

PIC programmer screen

Legend of the used colors:

Green Programmed and verified memory addresses.
Pink Programmed memory addresses, not yet verified.
Grey Erased memory addresses.
Blue Memory addresses to be programmed.
White Unused memory addresses.
Cyan Memory addresses to be erased.
Yellow Reserved memory addresses (containing the self programming code).
Red Data mismatch found during verification

The PIC programmer plug-in has some limitations:

  • The self-programming routine is not able to reprogram the configuration word, so you better get that right from the start.
  • You need a dead-sure way to enter the self-programming routine, even if your code doesn't behave as expected. Possibilities are to use an input pin that is checked soon after startup, or check that the TO bit in the STATUS register is cleared, indicating the device was reset due to a watchdog timeout.
  • To allow the plug-in to detect the presence, location, and version of the self-programming routine, the address of the SelfProgMagic symbol must be loaded at address 0x0003 in program memory. This can be achieved using the following code:
                    ORG     0x0003
                    data    SelfProgMagic
    
Normally, I2C boards are being polled from the Homevision schedule using one or more periodic events or timers. To avoid problems with both the operation of the schedule and the programming of the PIC, the plug-in can disable the periodic events and halt the timers when in programming mode. Which periodic events and timers must be stopped can be configured. It may also be a good idea to temporarily disable the infrared receive function when reprogramming a PIC.

The plug-in keeps track of the individual settings of each expansion board, in case more than one self-programmable board is connected to the HomeVision expansion bus.

The self programming code has been used in the Mini MFEB project.

Last modified: 29 Nov 2009, 13:34 CET