How to program
The PIC12C508A is a very old chip and can
only be programmed one-time. Use PIC12F629.
PIC16F84A is old and expensive. Use PIC16F628
We have been asked by a number of
subscribers, to provide the information needed to program a PIC12C508A, in
a single article.
All the tools, programs and routines to
carry out this operation
are on our website
and it's just a matter of having them all in easy
That's what we will do now.
To create a program for a PIC12C508A is very easy but since this chip is a
one-time programmable (OTP) device, you don't want to waste any during the
It can take up to 100 "tries" before a
project is working perfectly.
To prevent wastage we have devised a method where you use a PIC16F84A to
hold the program during the development stages and when everything is
running perfectly, you "burn" a PIC12C508A. For this you need an
8-pin to 18-pin adapter to allow the PIC16F84A to plug into
project requiring a PIC12C508A.
This means you are learning to program the PIC16F84A at the same time!
All you have to do is put the utilities we have listed below on your desk-top and
connect the Multi-Chip Programmer
to your serial port and you are ready to start.
A little Background
The '508A is an 8-pin microcontroller with 5 input/output lines and one
input-only line. It has an internal 4MHz clock and can be used for many
The days when an 8-pin chip was just a timer, oscillator, amplifier or
op-amp, have gone.
An 8-pin chip can now be a complete dialing
alarm or the heart of a random sequencer, a battery monitor or
security-code identifier, just to mention a few. We have provided a number of projects
on our website that use this
chip and Robot Beacon is an ideal staring place.
If you are new to electronics, you will need to read our
Basic Electronics Course. It gives you all the
information about circuit
components as well as chips containing gates.
Circuit Symbols Library is the largest on the web and contains
every symbol you need. You will also lean
how to interface (connect) items to a chip, including connecting to a
microcontroller. The course also covers transistor stages, such as the
common emitter stage and you will gain the background you need to
understand the symbols in a microcontroller circuit.
The next step is the
PIC Microcontroller Course. It covers the PIC12C508A
and PIC16F84A. These are the two devices we will be using. See the
Here are the steps you will need to put a program into a PIC12C508A:
Put the project you are developing on your work-bench.
For simplicity, let's say you want to modify the Robot Beacon
Here is what you will need: (Some of the items are in the PIC Programaming
CD containing this course is available for $9.95)
on your desktop.
datasheet (zip)(800kb) (unzips to pdf)
2. Put the blank template:
BlankF84.asm into Notepad and
rename it: Beacon-2.asm
3. Read the project:
4. Here are the data sheets and files you will
Library of Circuit Symbols
A complete Library of Routines to help you with creating a program
is only available in our subscription section. In the Index, the top green frame has a link "Extra Pages." Click
on page "10" and the 185k file will appear. The Library covers
everything you will want to do such as "Change direction, Compare,
Decrement, Delay, FSR, Increment, Input, Mask, Move, Output, Poll, Return,
Rotate, SetUp, Shift, Swap, Table, Toggle, TRIS, Wait, XOR, Zero Flag, and
To create a program, you can pull-apart
Beacon-1.asm, or start a-fresh by
getting the code for
SetUp and put it in the file:
It's always easiest to pull-apart a previous program, however if you are
starting from the beginning, use our preferred method of layout: (SetUp,
sub-routines, then Main) and create a sub-routine. Keep Main at the
end of your program.
The first sub-routine you will need is a Delay routine, so that anything
you output to a LED, will be displayed for a period of time so it can be
Any program you create will be loaded into a PIC16F84A and tested in the
project via the
8-pin to 18-pin adapter.
This means you must only use
instructions that are common to both chips. All the instructions in SetUp
can be understood by a PIC16F84A and PIC12C508A.
The layout below shows how to write a program that can be read by the
assembler to produce code for both a '508A and 'F84A. Click
program you can copy and paste into Notepad.
If your program requires less than 256 bytes of space (half the memory of a
'508A), you will have no problems with the CALL limitation of a '508A.
;Project: "Rotating xxx" - for F84A and then for a
You don't have to put anything here for: (__CONFIG) as the program
below will be assembled in
as the "Processor" (Click on Default for Radix,
Warning Level, Macro Expansion, and Hex Output.
Click Error file and List file. Tab size: 8) and the
CONFIG values will be produced. Load:
Source File Name into the window as "NewIdea.asm"
and click Assemble. You will get a NewIdea.hex
file. Burn a PIC16F84A and put it into the Adapter
Socket in your project and keep modifying the file
until the project works perfectly. When it works
perfectly, select 12C508A in
and burn a '508A.
;Start of memory for program
;Load W with 0000 1000
;Make RB3, (GP3) input
;Make GP2 an output & disable weak pull-ups
;Make GP5 HIGH
If your program requires more than 256 bytes (instructions), the simplest
is to use the first 256 locations and if any more sub-routines are
required, they are accessed as a GOTO. At the end of the sub-routine you
place a GOTO to take the microcontroller back to the Main program. Remember
this: any sub-routine with a GOTO can only be accessed ONCE from Main. If
you want to access a sub-routine many times, put it in the first 256
locations and use CALL. Always put Tables in the first 256 locations.