Can a PIC microprocessor update itself?

Thread Starter

RGT_UK

Joined Nov 10, 2015
11
This may seem an odd question, but using a Comms protocol over a network socket, usb or infra-red reciever is it possible that the chip could receive an update version of the code that was loaded originally, and save it into memory, then reboot/restart itself to execute the new code?

The reason I ask is that we are looking at using a 8-bit PIC chip for a project but the software could be updated/improved as time goes on and we would like to give end users a way of keeping up to date. If we are asking too much of these chips, is there a better option that would allow us to do this?
 

nerdegutta

Joined Dec 15, 2009
2,676
In my day job, I have a device that's running an ATMEGA 2561. This device have a GSM module connected, and when the vendor makes changes to the 2561's firmware, the device downloads it and installs it. Everything is done automatically.
 

spinnaker

Joined Oct 29, 2009
7,837
Look up "bootloader". Normally it is used to program a pic without a programmer but it could probably be modified for the pic to ask for the update.
 

JohnInTX

Joined Jun 26, 2012
3,976
Here's a list of boot loader apnotes from uCHIP. Many PICs can rewrite their own flash in blocks so the general idea is to have the bootloader firmware in a safe area of flash then communicate with it to load the new program image. Pick a chip that has block-oriented protections in the flash to help protect the loader firmware. I've implemented a couple that work OK. You'll need a robust communication protocol with error checking and recovery (power failure during update-now what?). It needs to be aware of the fact that while the PIC is updating a block of flash, its goes completely inert for a few milliseconds. But, it's all doable with some work.

Another approach is to use a PICkit3's Programmer To Go capability. The new firmware is stored in the programmer and a tech/user connects it to the ICSP port and presses the button. Microchip endorses a few third party ones as well. The attraction here is you don't have to develop boot loader code. I personally would avoid any non-uCHIP or non uCHIP-endorsed programmer.

Good luck.
 
Last edited:

Thread Starter

RGT_UK

Joined Nov 10, 2015
11
Guys,
Many thanks to all of you for that. It gives me the basis to read up, seek and find out how its done.

Cheers
 
Top