Configuring the User Space

This example details how to configure the User Spaces so that it only contains a Byte Space of 200 bytes and a Long Space of 400 bytes. This entails that the User Space uses the first 600 memory cells. Moreover, the I/O Config Space is removed since we don’t need it here (this space uses the last 44 memory cells).

 

1) Sketch: 4_EEPROM \ 2_UserSpaceConfig

In this program, we use the variable “HC_eeprom” supplied by the library to configure the specialized spaces during the setup().

We first configure the User Space using HC_eeprom.setUserSpace() so that it only holds 2 sub-spaces: The Byte Space and the Long Space. Their sizes are specified in bytes.

Finally, we retrieve the number of elements contained in these sub-spaces using HC_eeprom.getUserSpace_DataQty() and we display them on Analog Data 0 and 1. The number of elements contained in a sub-space depends on its data type and size.

#include <HITIComm.h>


// run once at power on
void setup()
{
  // initialize library
  HC_begin();

  // configure User Space (sub-spaces sizes)
  HC_eeprom.setUserSpace(
    0,     // Boolean space : default 50
    200,   // Byte space    : default 100
    0,     // Integer space : default 200
    400,   // Long space    : default 250
    0,     // Float space   : default 250
    0);    // String space  : default 8192

  // retrieve the number of elements contained in the sub-spaces
  HC_analogDataWrite(0, HC_eeprom.getUserSpace_DataQty(HC_USERSPACE_BYTE));
  HC_analogDataWrite(1, HC_eeprom.getUserSpace_DataQty(HC_USERSPACE_LONG));
}


// run repeatedly after setup()
void loop()
{
  // communicate with HITIPanel
  HC_communicate();
}

 

2) Control Panels

  1. Display the ANALOG Data Control Panel (“HITI” button).
  2. We can see that the Byte Space contains 200 Bytes and the Long Space contains 100 Longs.

    image301.png

 

3) EEPROM Panel (User Space)

  1. Open the EEPROM Panel (CTRL+E or Tools\EEPROM). As you can see, the User Space only contains the Byte Space and the Long Space.

    image303.png

  2. Display the Global Space (“Global” button).
  3. Use the navigation arrows to go through the cells. After address 600, you will notice that all cells are grey which means they are not assigned to any User Space.

    image305.png

  4. Display the Byte Space (“Byte” button).
  5. Go to the last index by using the navigation arrow. As expected, the last index is 199, which is normal since there are 200 Bytes.

    image307.png

  6. Do the same check with the Long Space. You should find that the last index is 99.

    image309.png

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.