Go to the Index page
Main page Products News Software Support Where to Buy SiteMap

Web51-C

Web51-C is a development kit for creating embedded Ethernet UDP and SNMP applications based on the 8051 microcontroller family.
Web51-C is a migration of the Web51 project that was completely written in assembler, to the C language. The free SDCC or the commercial KEIL C51 compiler can compile the application code.


The Web51-C project should be compiled based on the current HW (starting with the first KB of internal RAM if using a newer x51 microcontroller (e.g. AT89C51RD2, RE2). More memory (RAM) is required if programming SNMP applications.

An example of target hardware is the Charon I module, which contains enough memory to embed all of the Web51-C applications.
This document describes the installation and testing of some of the Web51-C applications.


The basic description of Web51-C project

  • Rapid application development
  • The source codes in ANSI C  
  • Uses an Atmel AT89C51RD2 microcontroller and Realtek RTL8019AS Ethernet controller 
  • Fully open HW and SW platform. 
  • Compatible with our simple, low cost and powerful HW solution (Charon I + Development Kit or Charon I + Charon I&II Development Board)  
  • Available in fully documented source code. 
  • UDP/IP stack implemented
  • Examples are SDCC (Small Device C Compiler) compatible 
  • Examples for the commercial Keil C51 compiler available 
  • Fully developed SNMP application called “SNMP I/O Thermometer“ using JAVA visualization 
  • Detailed description and getting started guide.
  • Cheap Development Kit with tested HW board & SW source codes.

 

Download

Web51-C – Getting Started

Detail description which compilers are used and why. Developing and debugging the applications in the Keil and SDCC compilers. Full Step-by-step manual how to test default application SNMP Thermo Meter..
Download : Web51C_SNMP_en.pdf

 

Web51-C – Evaluation version

Evaluation version of the Web51-C systeme. It's self-extract installer for Win32. contains :
  • Full source code of the UDP stack
  • Ethernet controller driver in .LIB version only
  • SNMP demo examples as .HEX files only, no source code

 
 

The Functional Block Diagram of Web51-C

Demo Version


 
 

ANSI C - SNMP Development System



Project Hardware

The project is based on the Atmel AT89C51RD2 microcontroller and the Realtek RTL8019AS Ethernet controller. We use our Charon I built-in module for the target applications. You can find the detailed description of this module in the attachments section or on our web site.

The memory sub-system is made by the

  • Integrated FLASH 64 kB memory (program code),
  • Integrated EEPROM 2 kB memory (configuration parameters),
  • External SRAM 32 kB memory (XRAM memory access),
  • Directly mapped peripherals - RTL8019AS Ethernet controller.

 
Address Space
Used
0x0000 – 0xFBFF
FLASH 63 kB (CODE)
0xFC00 – 0xFFFF
Bootloader 1 kB
Sheet.1 The memory Sub-system of Web51-C – internal program CODE memory

Address space
Used
0x0000 – 0x7FFF
SRAM 32 kB (XRAM)
0x8000 – 0x801F
RTL8019as Ethernet controller
0x8020 – 0x80FF
Free for the additional HW
0x8100 – 0xFFFF
Overlaps 0x8000 – 0x80FF address space
Sheet.2 The memory Sub-system of Web51-C - external data XRAM memory

Address space
Used
Address space
Used
0x0000 – 0x03FF
SRAM 1 kB (XRAM)
0x0000 – 0x07FF
EEPROM 2 kB
Tab.3 The memory Sub-system of Web51-C - internal data XRAM and EEPROM memory

Using the ISP method with the AT89C51RD2 serial port (see chapter “Firmware Programming) performs the programming of the internal FLASH and EEPROM memory. This method requires no additional hardware and fully eliminates using of a classical microcontroller programmer.

The Realtek RTL8019AS Ethernet converter is connected in the minimal mode without the external 93c46 EEPROM memory. The communication with the controller is in 8-bit mode, which allows you to address the 8kB of controller’s internal SRAM memory. This internal memory is used for receiving and transmitting the Ethernet packets. After the Ethernet controller receives the packet, an interrupt signal generated.

Recommended Hardware

The examples provided were originally developed for the Charon I module and work with the following development kits:
 
Charon I DK (Development Kit) is a simple and low cost development kit which you can use for testing and final applications. It contains only basic peripherals.
Charon I&II DB (Development Board) is a development kit which contains direct inputs and outputs, shift registers for external inputs/outputs, LCD display connection and direct 1-Wire output. The Charon I&II DB also contains a second serial RS-232 port, JTAG, SERIAL FLASH up to 4 MB and an ISP programming interface.

Either of these two development boards is recommended for testing your application. Your production product should use the Charon I or II module combined with your product specific peripheral circuitry.

Supported Peripherals on the Charon I&II Development Board

Serial shift register I/O Ports

The DB series boards contain serial shift register support for extending parallel I/O. The input/output width (maximum 32) depends on the number of connected shift registers. This extended peripheral mode can be enabled by a special set command issued from either the JAVA application or snmp client. In the “parallel“ mode, you can access the microcontroller’s P1 8 bit I/O port directly.

  • 0 .. 32 binary inputs
     
  • 0 .. 32 binary outputs
     
  • Serial port RS-232
    All incoming serial port data are packetized and sent as traps to the SNMP client.
     
  • Up to 4x 1-Wire thermometers
    The 1-Wire interface is typically used with the DS18S22 or DS18B20 temperature sensors. It’s connected to GND, +5V and DATA. You can connect up to 4 1-Wire thermometers, there are auto detect routines for searching more temperature sensors.

Software Methodology

Because the Web51-C project relies on using every bit of horsepower in a resource limited MICROCONTROLLER, the project needed to be architected to minimize these limitations. Project prerequisites are:
  • The use of the higher programming language such as ‘C’
  • Dynamic memory control
  • Peripheral access via special pre-programmed functions
  • Basic network protocol implementation
  • Fast system response time
  • Well documented for support and application integration

Choosing the C language compiler for Web51

Basic Environment and operating criteria:
  • The Web51-C system kernel must be complied by at least two different compilers (a commercial and free one)
  • The application development must be available for both Windows and Linux machines
  • Applications must be able to be quickly developed

GNU SDCC Compiler (Small Device C Compiler), a freeware compiler, is much better as compared to many commercial projects. We can say, with confidence, that it is situated somewhere in the middle of the compiler ranking list. However, It lacks an IDE and many additional development tools found in commercial products. The expanded C language 8051 syntax is included and it’s the same as in the Keil compiler. So, it is easy to write programs for SDCC that are directly portable to Keil.

However, because of the lack of an IDE, you need to be well skilled in using the GNU tool chain (make, ar, etc.) when programming applications with many separate modules.

Keil C51 is one of, if not the best C compiler in the 8051 world. It has an integrated IDE, so the project development cycle is easier.

Note: The Keil compiler uses the Big Endian method for saving the data to the memory compared to SDCC, which uses the Little Endian method.
 

The project folder structure

The Web51-C project is divided to the following folders:

web51c\app ... The user applications (for instance the demonstration examples)
 
web51c\bin ... The other Web51-C system Add on programs (e.g. RD2-Flasher)
 
web51c\dev ... Hardware device drivers (e.g. RTL8019AS Ethernet controller driver)
 
web51c\doc ... Documentation
 
web51c\include ... The Web51-C system header files
 
web51c\lib ... Pre-Compiled libraries (udp, snmp library and so on)
 
web51c\net.. The Web51-C system source codes.
 

The network protocols implemented in Web51-C project

The integrated UDP/IP protocol stack covers most of the OSI reference model. The following layers are implemented:

Data link layer

  • Sending and receiving packets using the Ethernet II standard.
  • ARP (Address Resolution Protocol) which allows one machine to find a peer machine’s MAC address given it’s IP address. '
     

Network layer

  • IP (Internet Protocol) – The basic network service, which sends the packets, based on the network IP addresses in the packet’s escription.
  • ICMP (Internet Control Message Protocol) – The control report protocol, which allows the system to send the error reports or other necessary information (i.e. ping).

Transport layer

  • UDP (User Datagram Protocol) – Connectionless transport service between two stations on an inter/intranet.

Application layer

  • SNMP (Simple Network Management Protocol) – This protocol supports the information transfer for network management. It is used for the monitoring, control and administration of devices on a network.
  • DNS (Domain Name System) – It allows the IP address -> Name mapping.
  • WOL (Wake On Lan) – Switching on the device in the local network based on packets destined for it.
  • Application specific protocols, which are used in the user defined applications (for instance The Temperature Measurement example)

The SNMP implementation was developed only for the Keil C compiler.

Developing and debugging the applications

Application development is done on either a Linux or Windows platform. The programmer should choose between the SDCC (compiled using make files) and Keil (µVision2 IDE environment) compilers. There are several example programs for better understanding the Web51-C programming in the web51c\app folder.

Developing Applications in Keil C51

Linking the applications is done in the µVision2 IDE environment, which contains an integrated compiler, linker and debugger.

The AT89c51RD2 processor’s EEPROM memory configuration

The Web51-C system uses the internal EEPROM memory to save configuration parameters (see example 1). It is necessary to configure it in the following manner:

The source codes of the example are co-located with the web51.uv2 project. The project includes the information useful for the compiler and linker together. You can open the project in Project -> Open Project menu, where you have to add the following path: \web51c\app\00.eeprom.setup and choose web51.uv2 project.

The project’s information is displayed in the left window:

  • The SRC folder – the source code of the eesetup.c (EEPROM SETUP) program,
     
  • The INC folder – the header files of the Web51-C system,
     
  • The LIB folder – the Web51Udp.LIB used libraries Web51Udp.LIB (The whole Web51-C system including the UDP protocol stack).

The T89c51RD2 processor's EEPROM memory configuration

The Web51-C system uses the internal EEPROM memory to save the configuration stuff (see the example 1). It is necessary to configure it in the following way:

The source codes of the example are situated in the web51.uv2 project. The project includes the information useful for the compiler and linker together. You can open the project in Project => Open Project menu, where you have to add the following path: \web51c\app\00.eeprom.setup and choose web51.uv2 project.

There are the project’s information displayed in the left window:

  • The SRC folder – the source code of the eesetup.c (EEPROM SETUP) program
  • The INC folder – the header files of the Web51-C system
  • The LIB folder – the Web51Udp.LIB used libraries Web51Udp.LIB (The whole Web51-C system including the UDP protocol stack).

 

fig. 1: Keil C51 - µVision2 IDE

ETH_ADDR MY_ETH_ADDR = {{0x00, 0x0A, 0x59, 0x00, 0x00, 0x00}}; 

                                                        // Web51 MAC address

IP_ADDR  MY_IP_ADDR  = {{192,168,6,68}};		// Web51 IP address

IP_ADDR  GW_IP_ADDR  = {{192,168,6,254}};		// mask

IP_ADDR  NETMASK     = {{255,255,255,0}};		// Gateway IP address 

The IP address values must be set to be corresrespond with the other IP addresses in the local network, where the Charon device is connected.

Build a project in the Project => Build target menu. The following files are created after the compilation is done:

File name
Description
WEB51 input data for debugger
WEB51.HEX the program code (this file is be transferred to the MCU)
WEB51.M51 symbol table
WEB51.OPT current settings of µVision2 (opened files, window size, …)
WEB51.UV2 project file
EESETUP.C source code
EESETUP.LST the output compilation list

Note: The compilation result is in the bottom of Figure 1. The Web51Udp.LIB library contains some of the information, which is not used in the program. That’s why the compiler reports 14 warnings. These warnings are not an error, but only a notice, that we have increased the code size without any effect. The user can remove the functions, which are not used during the compilation process in the \include\config.h file. This step is recommended for more advanced users.

You can upload the firmware (the result of the compilation web51.hex) to the Charon I module using the flash.bat file (saved in the same directory as the project as well).


Fig. 2: The program's output to the serial port 9600, N, 8, 1

The EEPROM memory should now configured. If the data were stored successfully, the screen in Figure 2 is displayed following module reset.

Web51-C system applications

The following describes the basic use of the Web51-C system. Communication between the Charon I module and PC is performed using the UDP example shown. The program receives the sent data by PC at the IP address, port 2000. The UDP packet’s data are displayed to the standard output port (serial port).

Open the project in the µVision2 environment (see the guide in the previous example). The source code of the example is stored in the web51c\app\02.udp.client folder.

The main function

The whole program is in the udpclient.c file. We have to reserve the memory for the incoming UDP packets at first :

u_char EthFrmBuf[ ETH_FRM_SIZE ];   /* The memory for the received UDP datagram */

data WORD EthProt;		    /* The type of the detected protocol */

The next step is the Web51-C system initialization

  • Setting the serial port parameters (9600,N,8,1),
     
  • Reading the configuration from the EEPROM memory,
     
  • Initialization of the ARP CACHE
     
  • Initialization of the RTL8019as Ethernet controller.

W51SystemInit();  /* Web51-C system initialization*/

W51VerStrComp();  /* Displaying the actual system version to the standard output */

W51SysInfo();     /* Displaying the configuration (MAC, IP address act.) */

The main program loop is split to two parts:

The program tests the RTL8019as input. If ethernet packet data are available, they are loaded using the W51EthReadData() function to the XRAM memory. The protocol type is then decoded from the (ARP, IP act.) datagram header.
  • W51ArpInput() – treating the ARP query/answer,
  • W51IpValid() – the IP datagram integrity check (CRC,IP address, act.),
  • W51IcmpInput() – treating the ICMP query/answer,
  • W51UdpValidCRC() – The UDP datagram check (CRC valid),
  • W51UdpValidPort() – valid (opened) UDP port in Web51-C system,
  • W51DisplayUdpData() – sending the UDP datagram to the standard output.

    if( RTLIrq0 ) // check for received ethernet data

                  // test RTL8019as interrupt request line

    { W51EthReadData( &EthFrmBuf[0] ); // read data from ethernet controller



      EthProt = MAKEWORD(EthFrmBuf[12], EthFrmBuf[13]);



      // --- decode received ethernet frame data --- //

      if(EthProt == 0x0806) W51ArpInput( (ARP_FRAME *) EthFrmBuf );  // ARP

      if(EthProt == 0x0800)                                          // IPv4

      {if( W51IpValid((IPv4_FRAME *) EthFrmBuf))

       {if( EthFrmBuf[23] == IP_Prot_ICMP )                          // ICMP

         W51IcmpInput((ICMP_FRAME *) EthFrmBuf);

        if( EthFrmBuf[23] == IP_Prot_UDP )                           // UDP

        { if( W51UdpValidCRC( (UDP_FRAME *) EthFrmBuf))

          { // decode received UDP datagram here

            if(W51UdpValidPort((UDP_FRAME *)EthFrmBuf))     // available UDP port

            { W51DisplayUdpData( (UDP_FRAME *) EthFrmBuf);

            }

          }

        }

       }

      }

    }

The Web51-C system management – ARP cache management, is finding the physical address of the MAC interface for the IP address (ARP resolver).

W51ArpManagement();    // updata arp cache, resolve remote hosts,...

The application functionality check

Build the program with Project => Build target menu, upload the web51.hex file to the Charon I module. Try to ping the module to check the availability (for instance ping 192.168.6.68).
 

Fig. 3: The Web51-C system response

There is an udp_client.exe PC application for testing the example stored in the web51c\app\02.udp.client\udp.client.pc folder. The application reads the data from the standard input (a keyboard) and sends them to the port 2000 of the module.

Running the UDP client on PC:

udp_client 192.168.6.68.

Fig. 4: udp_client.exe running on the PC

Enter the test string „Web51-C project based on T89c51RD2 and RTL8019as.“. You can see the received data by Charon I module on Fig. 5:


Fig. 5: The received data by the Charon I module displayed by serial port terminal.

The Web51-C system demonstration examples

The We51-C system contains the following demonstration examples for better understanding of the topics:
  • EEPROM – The EEPROM memory of the Web51-C system.
     
  • Wake On Lan – Switching on the station using the UDP datagram.
     
  • UDP client – Receiving the UDP datagram and displaying the data to the serial port.
     
  • UDP server – Sending an UDP datagram to the set IP address.
     
  • UDP echo server – Receiving and than sending back the UDP datagram.
     
  • ICMP ping – The remote computer availability test using the ICMP test report.
     
  • SNMP I/O Thermometer – Using the SNMP protocol for the temperature monitoring and controlling the I/O pins.

Note: The Web51-C system uses the serial port of the T89c51RD2 processor as the standard input/output. You can use any standard serial terminal to display or send the data. You need to set the communication parameters to 9600, N, 8, 1 and disable data flow control.

Example 1 - EEPROM

The Web51-C system uses the T89c51RD2 internal EEPROM for saving the configuration parameters as for instance IP, mask, gateway and so on.
 
Address
Description
Length [B]
0x000
Web51 MAC address
6
0x006
Web51 IP address
4
0x00A
Mask
4
0x00E
Gateway IP address
4
0x012
DNS server IP address
4
Table.4 The internal EEPROM memory structure of the Web51-C system

The program sets the Web51-C configuration parameters to the following values:

  • Web51 MAC - The MAC address reserved for the Web51-C project. 00:0A:59:00:00:00.
  • Web51 IP address – 192.168.6.68
  • Mask – 255.255.255.0
  • Gateway IP – 192.168.6.254

The source code of the example: web51c\app\00.eeprom.setup.

Note: The SNMP protocol implementation uses its own adaptive EEPROM memory structure, which is not the same as described in the tab. 4.

Example 2 – Wake On Lan (WOL)

The Wake On Lan technology (Magic Packet Technology) was developed by AMD and Hewlett Packard companies. WOL allows switching on the computer on the local network using a special UDP datagram. The UDP datagram has to contain 6xFF sequence, where there is 16xMAC address sent behind this starting FF sequence. The computer must have the mainboard and the LAN board, which supports WOL. The WOL support has to be enabled in the BIOS.

The source code of the example: web51c\app\01.wake.on.lan.

Example 3 – UDP client

The program receives the data from PC sent to Web51 IP address and port 2000. The UDP datagram’s data are displayed on the standard output (serial port).

There is an application developed for testing this example called udp_client.exe, which reads the data from the standard input (a keyboard) and sends everything to Web51 system. The application is written in C language and you can build it using the MS Visual C++ environment or by using a free LCC-WIN32 project. IP address of the Web51 system is passed as a command line parameter for instance udp_client.exe 192.168.6.68.

The source code of the example: web51c\app\02.udp.client.

Example 4 – UDP server

The program sends a UDP datagram each second from the Web51 system to the IP address of the PC server to the port 4000. The UDP datagram contains the information about a temperature (simulated as an incremental value incremented each time the datagram is sent).

There is also a PC server application developed for testing this example called udp_server.exe, which receives the incoming data from the Web51 system. The application is written in C language and you should build it in MS Visual C++ or LCC-WIN32 as well.

The source code of the example: web51c\app\03.udp.server.

Example 5 – UDP echo server

The program reads the data from any UDP port, displays them using the standard output and replies the original datagram back as quick as possible. It is an enhancement of the example 3 demonstration, when the system works in a query-answer mode. You can use the udp_client.exe application for testing the example.

The source code of the example: web51c\app\04.udp.echo.server.

Example 6 – ICMP ping

The program tests the remote PC availability using the echo request and echo reply ICMP messages. It’s a ping command normally used by the PC.

The source code of the example: web51c\app\05.icmp.ping.

Example 7 – SNMP

The example provides a detailed demonstration of Web51 SNMP. The application controls the binary inputs/outputs, LCD display, serial link RS-232 and 1-Wire thermometer sensor.

You have to use the Keil C51 compiler to build it. Unfortunately the SDCC version is not ready yet.

In the last part of this text, an in-depth description on how to use the “SNMP I/O Thermometer“ application is provided. This is also available as a standalone document.

The SNMP source codes of the SNMP examples are stored in the following folders:

  • web51c\app\10.snmp.LED,
  • web51c\app\10.snmp.LED_table
  • web51c\app\ 10.snmp.LED_variable_all
  • web51c\app\10.snmp.serial_io

 

Conclusion

The Web51 project and its numerous applications have resulted from several years of development. It is regarded as a very stable platform in the embedded systems world. The Web51-C version greatly enhances network management capabilities and opens the way for monitoring, controlling and configuring network device settings.

 

Ordering

Available now! We have a minimum of 5 pcs in stock at all times. It can be shipped via FedEx next day all over the world. We accept payement by Credit Cards or Wire Transfer, check our prices in the PriceList.

Or try to contact your nearest distributor of our's products - International Distributors.

Complete shipment of Web51 - C [600 077] includes

PortStore SET photo
  • Charon I&II Development Board
  • Charon I embedded module
  • Europe or North American Power supply 9V / 300 mA
  • RS-232 LapLink cable (serial 2x DB9F crossed) for easy SETUP over RS-232 with using any PC serial terminal.
     
  • Printed Getting started Manual
  • CD with all software and Source codes for the UDP stack, All examples and similar...

 

Let's test it

You can have sample on your table in 5 days! Just fill OrderForm, fax it to our number and wait for confirmation email with the FedEx tracking number..

Please order item: "Web51 - C" OID is 600077


 

See related documentation

  • web51c\app\Readme.txt
    All the SNMP applications contain detailed readme file in English.
  • Charon I&II Development Board – The DB scheme and device placements.
  • Charon I – Documentation – Scheme, description of the Charon I module.
  • Project Web51 - http://web51.hw-server.com/  
  • www.Hwgroup.cz – The final product and solution documentation.


  

The Literature & interesting shortcuts


  Main page Products Support & Download Pricelist Contacts SiteMap  


HW group - Prague - Czech republic - Europe