EEPROM Memory Dump
One debugging feature I have been keen to add is the ability to see the EEPROM memory. This will aid the debugging of the code on the STM8S as it will be easier to see the data being consumed by the application running on the remote control. The EEPROM memory dump feature simply displays a grid of memory locations along with the contents.
Main Form
The main form has been modified to take values from the user and then to translate the contents of the user controls into data for the EEPROM.
For example, the carrier frequency needs to be translated into counter values for the PWM function in Timer 1. This could be sent over to the remote control as a frequency but then it would not be possible to verify if the remote control could generate the desired frequency until the remote control tried to use the values. If the Windows application is going to perform checks on the user input then it is logical that it should send over just the counter values and not the frequency. This offloads the code necessary to perform the translation from the remote control to the user application. Doing this makes the application on the STM8S smaller. Remember, we have an 8K code limit on the remote control when using the IAR compiler.
The first step is to make the controls on the user interface respond to the values being entered and also add a mechanism to show the form which will display the EEPROM memory:
EEPROM Class
The application will also need a class in order to hold the contents of the EEPROM. This class acts as an intermediary between the raw bytes in the EEPROM and the data displayed in the user controls. The properties in the class translate the bytes into data types which can be used by a C# application and visa versa.
For instance, consider the remote control name. The C# application would like to see a C# string object. In the remote control EEPROM this is a series of up to 16 bytes each holding one character. A property presents a convenient way of performing this translation. The EEPROM class will require a series of bytes to hold memroy contents:
private byte[] _memory;
The Name property can then translate the C# interface requirements into those required by the STM8S application:
public string Name
{
get
{
string result;
if (_memory != null)
{
int index = NAME_OFFSET;
result = "";
while ((index < NAME_LENGTH) && (_memory[index] != 0))
{
result += (char) _memory[index++];
}
}
else
{
result = null;
}
return (result);
}
set
{
if (_memory == null)
{
_memory = new byte[EEPROM_LENGTH];
}
if (value.Length > NAME_LENGTH)
{
throw new ArgumentOutOfRangeException("Name", string.Format("Name must be less than {0} characters in length.", NAME_LENGTH));
}
for (int index = NAME_OFFSET; index < (NAME_OFFSET + NAME_LENGTH); index++)
{
if (index < value.Length)
{
_memory[index] = (byte) value[index];
}
else
{
_memory[index] = 0;
}
}
}
}
Similar properties can be added for the carrier frequency etc.
EEPROM Form
The form displaying the EEPROM memory makes use of a Grid control in the Syncfusion Essential Studio Enterprise Edition Community edition. This suite of tools contains 650+ controls for a variety of platforms and has recently been made available at no charge to individual developers and small organisations with a low turnover (< $1m).
The form showing the EEPROM memory is simple and contains the memory contents and a button to close the form
The image above shows the memory when the following properties have been set:
- Name of the remote control (row 0x000, 16 bytes)
- Counter value for the PWM function on Timer1 (row 0x0010, first two bytes)
- Power LED status (row 0x0010, offset 5)
Conclusion
Development of the Windows interface is proceeding steadily. As much work as possible is being offloaded to the Windows application in order to streamline the code which needs to be written for the STM8S.
Tags: Software Development, STM8
Sunday, February 15th, 2015 at 8:47 am • Software Development, STM8 • RSS 2.0 feed Both comments and pings are currently closed.
Thanks for highlighting the free of charge Syncfusion controls, they look very useful.
They certainly do look useful. I’m still working my way through the samples.
[…] OpenIR application can now store and retrieve the contents of the EEPROM. The previous article demonstrated how the basic IR parameters can be stored and retrieved from the STM8S EEPROM. It is […]