FIGURE 1. μDice schematic.
be downloaded to the MCU using the
PICkit 2 programmer/debugger.
Firmware
I chose to develop the firmware
using the free CCS C compiler that
comes with the current free version
of the MPLAB® Integrated
Development Environment (IDE —
available for download at www.
microchip.com/MPLAB). This allows
for the development of firmware
written in C directly to the MPLAB
IDE. Keep in mind as you read
through this article or refer to the
firmware that some of the pre-processor directives and functions
are compiler-specific and will only
work in the CCS environment.
It is a good idea to download
the CCS compiler reference manual
from the CCS website ( www.ccs
info.com). This manual outlines
all compiler-specific pre-processor
directives, as well as a
library of functions that can
be used to minimize code-development time. I also
suggest downloading a
copy of the PIC16F57
datasheet from www.micro
chip.com and keeping it
handy, so that you can
reference such things as
register addresses and
control bit manipulation.
As for the code,
initializing device/control
registers, getting the inputs,
and outputting them to
the LEDs is fairly straightforward.
The pushbutton states are polled
periodically, and a debounce delay is
FIGURE 2. Linear
feedback shift register
used in μDice project.
January 2008 47