ADVANCED TECHNIQUES FOR DESIGN ENGINEERS
■ BY FRED EADY
PETER BEST CIRCLES THE DRAIN
NO. IT’S NOT A MISPRINT. Peter has been rotated out of the Design Cycle
and into the toilet ... literally! It may comfort you to know that Peter hasn’t
committed any felonious acts or taken any missteps in the outhouse. Mr. Best
has decided to leave his Design Cycle duties and take a position with the
Xerolet Corporation. Peter is in the toilet because Xerolet makes potties.
However, unlike the dumb (but proud) porcelain monument found in most of
our bathrooms, the potties produced by Xerolet are high-tech units designed
to be deployed in places devoid of communal waste treatment facilities.
You can take a look at what Peter has “fallen into” at www.xerolet.com. And,
yes. There are LOTS of potty jokes floating around the EDTP lab these days.
I am honored to be able to step in for Peter and we all wish him continued
success at Xerolet.
Peter and I worked together on the EDTP Ethernet MINI
C-to-PBP (PICBASIC PRO) conversion project that you
have been reading about in this series of Design Cycle
episodes. So, I’m up to speed and ready to go with this
month’s MINI driver conversion subject matter. We’ve
already gotten the basic driver stuff up and the latest EDTP
Ethernet MINI PBP driver code for ARP, UDP, and ICMP
(PING) was put up for you to grab via ftp last month. The
PICBASIC PRO MINI code you have access to right now is
enough to get the EDTP Ethernet MINI online. However,
adding a touch of DHCP to the mix will add some flavor to
our MINI stew.
JUST IN CASE
If you’re DHCP challenged, Peter presented the details
of the innerworkings of DHCP and the embedded coding
behind it all in a past Design Cycle column. If the concepts
that I am presenting in this discussion are unfamiliar to you,
I suggest refreshing your DHCP knowledge by checking out
past Design Cycle columns.
DHCP is short for Dynamic Host Configuration
Protocol. As Peter pointed out in his DHCP discussions,
DHCP is message based and through its services a
network client host such as the EDTP Ethernet MINI can
automatically obtain IP, gateway, and subnet mask
information from a DHCP server participating in the client
host’s network. DHCP is not difficult to understand,
and likewise, is not difficult to code into an embedded
14 October 2007
application. This month, our goal is to code a PICBASIC
PRO-based DHCP engine into the EDTP Ethernet MINI.
So, let’s get started.
DHCP WITH PICBASIC PRO
We’ll need to add some DHCP-specific PBP code
modules to our existing PICBASIC PRO-based EDTP
Ethernet MINI driver to get DHCP up and running on our
EDTP Ethernet MINI hardware. Specifically, at a minimum,
we’ll need to add a DHCP initialization routine, a DHCP
engine routine, a DHCP transmit message routine, and
a DHCP receive message routine to our existing code.
While we’re at it, we’ll also code in a routine to allow us
to display our received DHCP addressing information on
a personal computer running a terminal emulator
application. And, if that’s not enough excitement for you,
we’ll throw in some PICBASIC PRO code to broadcast our
newly acquired DHCP parameters using UDP and retrieve
the UDP datagram using a Microchip PC application called
PLANTING THE FIRST DHCP SEED
Before we do anything about building up the
aforementioned DHCP modular routines, we’ll need to tell
our main PICBASIC PRO operating loop about the DHCP
stuff we’re about to code up. Please consider the following
PBP source code snippet: