DESIGN CYCLE
current draw within the
published USB
specifications. If your
design needs to adhere to
the USB specifications in
this area, consult the
PIC18F Starter Kit User’s
Guide (Microchip
document DS51852A) for
more detail.
Unless you’re taking
advantage of Microchip’s
factory programming
service, your brand new
PIC18F47J53 will emerge
from its antistatic packaging as dumb as a rock with plated
pins. In our case, that’s a good thing as our USCM-47J53
has a PICkit3-compatible ICSP programming and
debugging portal.
I’m all for super simple and built-in debugging tools.
The LED falls into that category. So, I splurged and added
a free-floating blue LED with an associated 470Ω current-limiting resistor to the USCM-47J53 design. Normally, the
RS-232 portal is the most powerful built-in debugging tool
available. However, there is no RS-232 support hardware
designed into the USCM-47J53. The closest thing we have
to an RS-232 portal is a miniature USB connector and
some really tricky firmware.
■ SCREENSHOT 1. Once
you get the feel of what files
are needed, the coding and
realization of the project
comes a bit easier. The USB
stack is minimal and, as you
can see, the star of the show
is the usb_function_cdc.c
file which contains most of
the functions used in the
main.c application source.
■ SCREENSHOT 2. The Tera Term Pro terminal emulator
and the PIC18F47J53’s USB portal make for a
cheap and powerful debugging tool.
USB PORTAL FUNCTIONAL TEST
functionality of an RS-232 port with a mini-B equipped
USB portal, my little USB project is based on a CDC
(Communications Device Class) template. All of the
project files are revealed in Screenshot 1.
The HardwareProfile – PIC18F47J53 PIM.h file uses C
#define statements to associate switches, LEDs, and other
peripheral devices to the PIC18F47J53’s I/O resources.
Since our USCM-47J53 design is devoid of preplanned
LEDs and switches, the associations and resultant macros
have no direct effect on our test application. However,
there are a couple of lines of code within the
HardwareProfile – PIC18F47J53 PIM.h file we need:
The ability to implement an embedded USB portal
with only a mini-B connector and a
couple of printed circuit board traces is
one of the reasons the PIC18F47J53
was selected to host the USCM-47J53.
So, let’s establish a built-in serial
debugging tool and test the USCM-
47J53’s USB portal at the same time.
#define CLOCK_FREQ 48000000
#define GetSystemClock() CLOCK_FREQ
■ FIGURE 3. Note that the EA
DOGM162L-A SPI configuration is
also boosted with the external capacitor
pair. The PSB line is tied logically low to
enable an input only serial mode.
December 2010 57