|
Taking a Look at the PIC18Cxxx Series
by David Brobst
Start ý PIC18Cxxx
Chips ý Memory ý Data
Memory ý Advanced Indirect Addressing
ý Deep and Accessible Stack ý Interrupts
ý Power-On Features ý Clock
Speed ý 10-Bit A/D ý Hardware
Multiplier ý Timers ý CCP/PWM
ý USART ý I2C
Master ý Table Read/Write ý Current
Status ý Sources and PDF
TABLE READ/WRITE
For those of you who are not familiar
with the PIC17Cxxx series of controllers, perhaps the most
intriguing new feature on the PIC18Cxxx family is the table
read/write capability. This allows the PIC18Cxxx to directly
read from and write to its own program memory. Almost surely, the
most important aspect of the read capability is that it allows the
PIC18Cxxx controllers to perform program memory integrity checks
versus a checksum. This allows the PIC18Cxxx controllers to
periodically monitor their program memory and ensure that the code
is working properly and has not been changed.
For mission-critical systems, this is an
absolute must. Additionally, the read capability can be used to read
the configuration fuses and ID locations directly. These could then
be reported directly to a querying unit for inventory purposes and
system verification. Listing
3 shows the table read command
being used to read some of the configuration bytes.
More intriguing is the write capability.
Basically, the PIC18Cxxx chip can modify its program space
with executable code. Note that with the initial PIC18Cxxx
offerings, the program space is still EPROM-based and inherently one-time-programmable.
In the PIC18Cxxx, any non-programmed byte is all ones (FF hex).
A one can always be changed to a zero, but a zero can revert to a
one only through UV exposure. So if program space already has executable
code, writing over the program space with the table-write command
would simply destroy the code at best and make some new unintended
instruction at worst.
With this limitation in mind, there is
still a myriad of uses for the table write command that spring to
mind. Because the EPROM memory is OTP, any table write is going to
store information in a nonvolatile manner. Thus, the table write command
could be used for maintenance logs, serial numbers, time stamps, and
so on. In addition, if the reset code was appropriately designed,
the table write command could be used to patch existing code or provide
field upgrades.
This all sounds great in theory, however,
implementation is a bit more complicated. The first major problem
with the table write command is that it requires 12 V on the /MCLR
line. This is referred to as the programming voltage (VPP).
The tricky part for the table write command is providing the 12 VPP
on *MCLR when needed and then the typical reset voltage during other
times. This is a minor problem and easily overcome with a small amount
of inexpensive circuitry. Figure
4 shows a circuit that can be used to accomplish this.
Although these initial voltage and one-time
writes are limiting at the moment, it is easy to see where this functionality
can lead. On the drawing board for the PIC18Cxxx family are
flash memory versions of the part. When these become available, the
voltage and memory reuse problems should disappear. Listing
4 shows some code that implements
a table write to program memory. A pushbutton ends the programming
cycle and wakes up the controller.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |