The Design Cycle
Figure 3. This card was chosen for the AirDrop-P
series because of its descriptive and easy-to-under-stand LED modes and its internal PRISM chipset.
using the MPLAB ICD2 in
combination with the latest
version of Microchip’s MPLAB
IDE. Any Microchip-compati-ble programming/debugging
system can be used to enable
the AirDrop-P.
The business end of the
AirDrop-P is the 50-pin
CompactFlash connector that
carries the 802.11b wireless
LAN network interface card and
interfaces the CompactFlash
Listing 1. Here’s a bit of code that fires up the TRENDnet TEW-222CF wireless LAN
CompactFlash card. There is a lot of information here. Fortunately, we only need just a few
bytes of it to get our wireless project off the ground.
F
o
r
E
l
e
c
t
r
o
n
i
c
s
NUTS & VOLTS
E
v
e
r
y
t
h
i
n
g
32
card’s electronics to the PIC18LF8621.
Since the PIC18LF8621 is an eight-bit
microcontroller, the 16-bit amenities of
the CompactFlash connector are
unused and thus not connected. To
save PIC18LF8621 I/O, only the
CompactFlash connector I/O lines
that are absolutely necessary for
802.11b operation are connected
and used. For instance, the CD1 and
CD2 pins are used to determine if a
card is mounted correctly. Those
pins are left disconnected, as we
most likely won’t be hot swapping 802.11b CompactFlash
cards, and writing code to sense
these pins would be a waste in
our particular application of the
CompactFlash card.
A memory-mapped
approach to driving the
AirDrop-P was considered.
However, to keep the circuitry
and driver code as simple as
possible, a simple I/O interface
was adopted. Note that there is
absolutely no “glue” logic on the
AirDrop-P board. One of the
AirDrop-P design points was to
leave as many of the
PIC18LF8621’s subsystems
open for use and to leave as
many microcontroller I/O lines
open as possible without resorting to additional special purpose components. Also, using
the I/O interface allowed the use
of simple I/O code routines to
move data back and forth
between the CompactFlash card
and the PIC18LF8621.
All of the firmware to drive
our 802.11b application and the
CompactFlash network interface card (NIC) is contained
within the PIC18LF8621’s Flash
program. The CompactFlash
NIC is responsible for taking the
data we give to it and broadcasting it wirelessly to another wireless station or access point. The
wireless LAN card of choice for
the AirDrop series of 802.11b
development systems is manufactured by TRENDnet and is shown
in Figure 3. The TRENDnet TEW-
APRIL 2005
void init_cf_card(void)
{
//******* LOCAL DEFINITIONS
char cor_addr_lo,cor_addr_hi,cor_data;
char cis_device;
unsigned int cis_addr,x; // attribute memory index (EVEN ADDRS ONLY)
char code_tuple; // tuple type
char link_tuple; // number of body bytes in this particular tuple
char tuple_link_cnt;
char tuple_data; // current body, byte value for a given body
char funce_cnt; // there are 6 & the 4th holds the MAC addrs
char mac_cnt;
char rc;
//******* END LOCAL DEFINITIONS
//******* BEGIN CONTACT CF CARD
set_RSET;
SETUP_A;
SETUP_C;
SETUP_F;
SETUP_G;
SETUP_H;
SETUP_J;
FROM_NIC;
clr_RSET;
clrf_cis;
x = 500; //set up a time out timer
do{
delay_ms(2);
if(—x == 0)
{
break;
}
code_tuple = rd_code_tuple(0x0000);
if(code_tuple == 1)
setf_cis;
}while(!(bcisflag));
//******* END CONTACT CF CARD
cis_device = 0;
cor_addr = 0;
funce_cnt = 0;
mac_cnt = 0;
cis_addr = 0;
clrf_cis;
// reset to the first CF_CISTPL_FUNCE
// CIS starts at location 0 of Attribute memory
do{
code_tuple = rd_code_tuple(cis_addr);
cis_addr+=2;
link_tuple = rd_link_tuple(cis_addr);
cis_addr+=2;
if(code_tuple != END_TUPLE)
{
for(tuple_link_cnt=0;tuple_link_cnt<link_tuple;++tuple_link_cnt)
{
tuple_data = rd_tuple_data(cis_addr);
cis_addr+=2;