|
Part 2: Revving It Up
by Fred Eady
Start ı Tera
Term Pro ı Road Test ı The
Hardware ı As a Web Server ı Branching
Out ı Making Changes ı ReadyıSet?
ı Go ı Sources
and PDF
AS A WEB SERVER
The S-7600Aıs protocol stack allows the
S-7600A/PIC16F877 Internet Engine to play many roles. In addition
to a web server, the S-7600A/PIC16F877 Internet Engine can be configured
as a TCP/IP client or an e-mail generator. In this section, Iım going
to show you how the S-7600A/PIC16F877 Internet Engine can be programmed
to serve a simple web page.
The process begins with the menu you see
in Photo 4. After the username, password, and ISP phone number are
entered, the date and time can be set and an HTML page can be loaded
into the serial EEPROM. Iıve supplied a sample HTML page in Listing
3. The time and date are taken
from the DS1629 and inserted into the page just before it is served.
Listing
4 is the code necessary to implement
the web server application on the S-7600A/PIC16F877 Internet Engine.
Letıs start at the top and work our way down. As an experienced PIC
programmer, I found the PCW C package refreshing. The engineers at
Microchip were good enough to provide most of the supporting include
code that does the housework. All of the EEPROM, S-7600A, and PIC16F877
include files were provided by Microchip. So, building up the
S-7600A/PIC16F877 Internet Engine and the accompanying software was
like working with Lego blocks. The remainder of include files
are the standard C includes with PIC accents that come with the PCW
compiler.
I know how to write all of those I2C
and serial drivers, but itıs great to have them already written for
you. As you can see in Listing 4, the serial and I2C ports
are defined with a simple line of code for each. The standard_io
declarations help avoid a common problem with PIC I/O. PIC I/O is
so fast that reads and writes to the same pin can sometimes overlap.
The use of standard_io makes sure this wonıt happen by setting
the I/O pin for either input or output before the operation is performed.
This operation gives the I/O pin time to settle and assures a good
read or write to that pin. The rest of the pre-main area is standard
stuff. The normal PIC pin definitions are followed by the variable
defines.
PREVIOUS
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ıCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |