THEDESIGNCYCLE
ADVANCED TECHNIQUES FOR DESIGN ENGINEERS
■ BY PETER BEST
CONFIGURATION WIZARDRY
IF YOU’RE STANDING UP, MAYBE YOU WANT TO TAKE A SEAT. Last time, we
started our indepth look at what makes the C8051F120 a premier 8051 drop-in
solution. That Digital Crossbar stuff we looked at seemed mighty complicated.
Well, after taking some time to read the C8051F120 datasheet, I fell upon a
thing called Configuration Wizard 2. I’m sorry to have to break this to you, but
the Configuration Wizard 2 application takes every bit of complication out of
configuring any of the C8051F120’s general-purpose I/Os, peripherals, and the
Digital Crossbar. And, Configuration Wizard 2 is free as a download from the
Silicon Laboratories website.
USING THE SILICON LABORATORIES
CONFIGURATION WIZARD 2
I fired up the Configuration Wizard 2 application
and selected the C8051F120 as the target device. Up
popped an “untitled C8051F120” configuration window
that contained the following text:
*********************************************************
/////////////////////////////////////
// Generated Initialization File //
/////////////////////////////////////
#include “C8051F120.h”
// Initialization function for device,
// Call Init_Device() from your main program
void Init_Device(void)
{
}
// Empty configuration
// Open the “Peripherals” menu and
// choose a peripheral to configure.
*********************************************************
I took the liberty to save the raw Configuration Wizard
2 file as “.nuts_and_volts.cwg” (imagine that), which is
available on the Nuts & Volts website ( www.nutsvolts.com).
Keep in mind that I haven’t written a line of anybody’s
source code at this point. The Configuration Wizard 2
application automatically stuffed in the #include
“C8051F120.h” statement and built the Init_Device function
skeleton you see in the previous code snippet.
80 May 2007
I don’t know about you, but I’ve had close encounters
of the third kind with lots of configuration and program
wizards. My best advice to you is to read their output
messages and comments carefully and heed the wisdom
contained within the messages as ignoring a wizard’s sage
advice can lead to trouble. With that, I followed the light
offered by the last comment in the generated initialization
file and opened the Configuration Wizard 2 “Peripherals”
menu. What I saw is what you see captured in Figure 1.
CONFIGURING C8051F120
GENERAL-PURPOSE I/O PINS
I decided to go down the Configuration Wizard 2 Port
I/O path as we already examined how to logically set up bit
6 of Port 1 (P1.6) for output in the previous installment of
Design Cycle. Note that in Figure 2, I configured P1.6 for
push-pull digital operation and enabled the Digital Crossbar.
If you’re having trouble finding the P1.6 configuration
change, follow along the Push-Pull/Open Drain row near
the bottom of Figure 2. Note also that the code to perform
the P1.6 configuration operation appears in the bottom
window of Figure 2. If you look back to the previous issue
of Nuts & Volts, you’ll see the code that was generated
by the Configuration Wizard 2 application here to enable
the Digital Crossbar and set up general-purpose I/O
pin P1.6 matches the Digital Crossbar/P1.6 configuration
code we studied in the previous Design Cycle column. This
is promising.
This gets better. In the Port_IO_Init function snippet that
follows, I’ve culled out the C8051F120 general-purpose I/O
comments and code that we are most interested in: