Example of use myEthernet: Shared RAM

Project

    The myEthernet has a 4 kB big SRAM. A part of it can be reserved as RAM. This happens via the configuration file of the myEthernet which is on the SD-card. This shared RAM is a memory area in which the myEthernet can save data. The myEthernet can also display data from the shared RAM on a HTML-page. Furthermore devices which are connected with the myEthernet can write data in the shared RAM of the myEthernet and read the data from him. This happens via TWI.

Required hardware

    In this example the myEthernet should write the characters 'W', 'o', 'r', 'l', 'd', '!' in the shared RAM. At the same time the content of the shared RAM is displayed in different ways on the HTML-page.

    With help of the command you can save a byte kann in the shared RAM. This is appended to the end of the address in the address line. The command can also be triggered by a pointer.
    The pin number of the first Byte of the shared RAM is 1000. The value which should be saved in the shared RAM must be transfered as hexadecimal value, e.g. ?myChangeCmd=o10000x57



    If you want to insert a html reference then you have to pay attention to replace the characters ~ and by character codes
    (~ = %7E, = %B0) because the myEthernet web server interprates all text between the degree characters as replacement. A link must be look like this:

    To read out the current values you have to write in the HTML-source code. The value is formatted with v1000~%c. In this example as ASCII-character. n bytes are displayed with from the first byte separated with one comma. If you use pin numbers from 2000 then always the value from 2 consecutive bytes is displayed.
    The following graphic should clarify it:



    So there are the following areas for the pin numbers:
      8bit values: Pin 1000-1127
      16bit values: Pin 2000-2063
      32bit values Pin 3000-3031

Procedure

    Step 1:
    Create a HTM-file with the name shram.htm.

    Step 2:
    Write the following source code in it.



    Step 3:
    Copy the file on the microSD-card.

    Step 4:
    Insert the microSD-card in the myEthernet, connect the power supply on the myEthernet and connect it via the network cable with a PC.

    Step 5:
    Open a page in a web browser. Write in the address line the IP address and the name of the htm-file e.g. http://192.168.178.96/temp.htm

    Step 6:
    At the beginning there are random values in the shared RAM. Click on the 4 links. Because of that the 4 letters
      'W' (1. Byte),
      'e' (2. Byte),
      'l' (3. Byte),
      't' (4. Byte)
    are written in the shared RAM. Under the links there are the values which are in the shared RAM and which are displayed on the website.

    On the bottom there are screenshots of the website.


    Page before clicking the 4 links

    Page after clicking the 4 links

The shared EEPROM

    Data which are saved in the shared RAM are lost when you separate the myEthernet from the power supply. Thats why exists between the RAM also the EEPROM in which you can save permanently the data. The size of the shared EEPROM can be determined in the configuration file of the myEthernet.

    If you use the EEPROM then you have to pay attention that you can perform on it for only a limited number of writes. Thats why you shouldnt write measured data in the EEPROM every minute.
    The EEPROM is shared with the exception of the pin numbers as well read out and described as the Shared RAM. Instead of the ports 1000, 2000 and 3000 the EEPROM uses the ports 5000, 6000 and 7000.



Downloads

Shopping list:


««« Back to the picture gallery  

Our regional partners

Business partner wanted!

To expand our sales area we are looking for partners to represent our products and interests of the Laser & Co. Solutions GmbH.

XMC product line

myEthernet

mySmartUSB MK2