Project files

Linking order  web51_manual.html  Web51 Applications
As the Makefile description says, each project consists of several files. Here you will find an explanation of what is contained in each source file and how to order data in the FLASH (or EEPROM).

.HTML

Files, such as preconstructed HTML pages, end up stored in the Web51 memory (program Flash, internal or external EEPROM). Files are converted to .ASM by a rule in Makefile that uses the html2db.pl script. In the process, CRLF pairs (ends of lines) are removed which is not a problem for pure HTML. However, if the code contains Javascript, it is necessary to preserve ends of lines by adding the -appendlf option to the corresponding Makefile directive. See the LED3 example.

The "index.html" file should be reachable from a browser at the server root, "http://X.X.X.X/", in addition to "http://X.X.X.X/index.html". This is ensured at compile time by the -index 0 index.html option in Makefile. The -index 0 option creates another filesystem entry that associates server root with index.html.

In Web51 HTML files, the apostrophy (') has a special meaning - it calls CGI scripts. If you need to use apostrophy in HTML code, enter it twice. Two apostrophes will become one during compile. Compiler cannot verify CGI calls from HTML, since they are called at run-time when HTML is interpreted by Web51. Don't forget to add all CGIs to the project and include them in the resulting code.

.GIF .JPG .PNG

Of course, images can also be stored in Web51 memory (program FLASH, internal or external EEPROM). LED1 or the thermometer example use images. For linking, image files (e.g. GIFs) need to be converted to .obj. The html2db.pl script automatically finds out that it is a binary file. All you need to do is specify all used in the variables FILES and OBJS and add appropriate lines to Makefile to link them to the final code.

.CGI

CGI scripts are effective for passing data between HTML pages and programs that run on Web51 but have nothing in common with page generation (e.g. measurements). Scripts are usually coded in assembly. A script is called when the corresponding WWW page is ready for transmission; therefore, its execution should not take too long. Usually, a script only converts contents of a variable into a suitable form. Another option is to write the script in P-Code. Details about CGI files and their possibilities follow later.

www8051.asm

This is the main project source. At its beginning, .INC files with necessary definitions are included and memory for system variables is allocated.

Then, Main Loop follows with its .section fast, #alloc, and .section slow, #alloc. These sections should contain the code of the particular application. The FAST section is executed approximately every milisecond, the SLOW section executes once per 50 cycles of the FAST section. Sections are called from the main system code stored in web51.asm. Definitions of constants (including the slowtiming=50 constant) are in param.inc. These two sections should contain code that interfaces with hardware. Sections must be through and may not end with a ret instruction etc. (see reset_device section description). Subroutines, usually called with LCALL, can be placed in the last section of www8052.asm, which normally follows after the SLOW section and begins with .text.

If you need to execute some code after device reset or power-up only (peripheral inits etc.), add a .section reset_device, #alloc or .section reset_network, #alloc between the sections SLOW and .text. It will be called only once when the program starts.

The difference between the two is that first, all reset_device sections of all modules are executed, and then all reset_network sections of all modules. Interrupts are disabled in these sections. Sections must be through; they must not end with a ret or a similar instruction.

A simple example of the one-time executed section follows; a NOP is used instead of any initializations:

.section reset_device, #alloc

nop
.text
sensor_test: ..

Bear in mind that whenever a section ends, a different one begins. Program execution after the above NOP continues with instructions from another module with a reset_device section, not with the instructions that follow sensor_test.

Similar to these two sections is the .section one_times, #alloc, which contains code executed once at startup with interrupts enabled. Again, this section must not end with a ret.

Summary of project description

In this chapter, basic composition of Web51 projects was explained. If you are not proficient in assembly, the DOWNLOAD section contains a detailed reference of the assembler in the "Related documentation" section.

For further studying, we recommend to load the LED1 or LED2 examples into your HW KIT and begin with slight modifications.





Sponzored by LPhard Ltd. Graphics by GIMP Created by EasyPad

(c)Copyright 2000 - 2002, HW server & Radek Benedikt
Web51@HW.cz, Web51.HW.cz
Linking order  Obsah  Web51 Applications