Programing the PIC Processor

In order to get the PIC processor to do anything useful, we have to be able to program it. There are many designs for programmers on the web, but as the junk box only contained minimal parts, and as building an unknown programmer for an unknown processor was just to many unknowns me, I elected to buy a programmer.

After a little research (too little as it turned out) I bought a parallel port programmer on eBay. It was an Altronics programmer and I had checked that it would program the 16F675 and 16F628 chips that I also bought using eBay.

Unfortunately, I later found out that that programmer was only able to program the 16F628 not the later 16F628A processors that were more common at the time - I'd bought 3 16F628As. I proceeded to experiment with the 12F675s. Later I was able (through some trial and error) to program the 16F628As by modifying the Altronics Programmer, I'll document the modifications later in these pages.

Fuses

Each version of the PIC Microprocessor has some fuses that are set when the device is programmed. These fuses control the behaviour of certain i/o functions that could not be left in an unknown state until the program starts - the clock type for example.

Some of these functions, such as Low Voltage Programing and MCLR deprive you of an i/o pin when enabled, I find however that in the case of the MCLR pin, the Altronics programmer is not always able to re-program a chip without the MCLR pin to reset the chip whilst the programmer is starting up. This I gather is due to the PIC starting up too quickly for some combinations of PC and parallel port programer.

Whilst using the cheaper hardware, it is better to loose the I/O pin and know that you will be able to re-program the chip at a later date.

Another thing to take note of when programming the PIC is that many of the smaller versions come with a couple of locations pre-programmed with an adjustment to the internal clock. If you are going to use the internal clock rather than a crystal, this value must be preserved in order to do things like RS232 communication reliably. The preferred method is to take any new PIC that uses this method and read it with the programmer keeping a note of the value - this will have to be put back in manually each time the PIC is programmed.

In my rush to try things out, I missed this vital step, I now have a couple of the smaller devices that are only good for projects that use an external ceramic or crystal clock.

Languages

Although it is possible to program the PIC processors in assembly lnguage (with free tools available from Microchip and other sites on the web, larger programs are easier to work with using a higher level language. C would normally be a first choice for me having used it under DOS and Linux, and if you are going to shell out on a development board from someone like Forest Electronics then it makes sense to get one of their compiler packages.

I had a budget of Zero - I was doing this for fun, I did'nt know if the PIC was going to be a chip I would continue to work with, I needed something I could use on small projects whilst I learned the chip.

Searches for a free compiler that worked with the newer chips and included lib files for using the on-board peripherals turned up mainly demo downloads that would expire after a short time.

Then I found the free High Tech PICC-Lite compiler will work without restriction on the smaller PICs, and with some limits on program and memory size on others. The PICC-Lite compiler can also be used for commercial projects.

I also found the JAL compiler that is pascal like, and played with that for a bit. There is also the Blink a Led page with diagrams and examples and hex files for the classic 'Blink a Led' program. A hex file from this site for your chosen 'PIC' will easily show you that you have the chip powered and clocked correctly.

Also available is the BASIC Proton Development Suite - available in a lite version for non commercial use. I downloaded it and gave it a spin. The combined IDE allowed me to edit and compile under windows and the built in help is very comprehensive. The free version has a limit on the number of basic program lines that can be used and no possibility of 'including' files. For smaller projects, this limitation is not a problem and with the built in functions for handling the on-board peripherals, driving LCD and RS232 communications, a few lines of basic may be all that a small project needs.

Between them, the above packages allow me to learn the PIC processor, compile short programs that test a port pin or peripheral and output the value to the serial port or LCD, and work on more complex projects involving more of the PIC processors functions.

Boot Loaders

Due partly to the difficulties programming the 16F628As, their lack of i/o pins and the risk to a project board from continually having to remove the IC and insert it into my modified programmer, I once again turned to eBay and bought a couple of 16F876As.

Modifying the programmer further allowed me to program the larger chip, but I had come across Boot loaders that would allow the new program to be uploaded into the 16F876 (and similar PICs) via a serial port.

I use the Tiny Boot loader under windows. It needs level converters for TX and RX, and the ablity to reset the PIC when a new program is ready to download.

The boot loader doubles as a mini terminal, so once the program is loaded and the PIC reboots, I can see any program output without having to load another program. Once any new chips have been programed with the boot loader, the parallel port programmer is not needed.

Experimenting with Microchip PIC 16F876, 16F628 and other Processors

Introduction
About the PIC Processor
Programing the PIC
Building Blocks
PIC Test Rig

Connecting an LCD
VoipDeskPhone
VoipDeskPhone the Software
VoipDeskPhone3 Changes for use as an Asterisk Console Phone

Cheap PIC Keypad PoundShop Clock / Alarm = Cheap Keypad

3 State LEDs

Add DRAM to a PIC
PIC Links


Google
 
Web picprojects.247n.com

Computer and Electronics Project Notes