Syntax:
EEPROM DataSetName [[,]address] // multiples values, strings etc. 0,1,2,3 END EEPROM
Command Availability:
Available on all PIC microcontrollers with EEPROM memory. AVR support required use of AVR-ASM assembler. GCASM does not support AVR EEPROM operations.
Explanation:
The EEPROM construct creates an EEPROM dataset for use with the specific microcontroller. An EEPROM dataset is a list of values that are stored in the EEPROM memory of the microcontroller, which then can be accessed using the EPREAD() command or other EEPROM read operations.
The advantage of an EEPROM dataset is that they are memory efficient being loaded directly into the EEPROM during programming operations.
EEPROM datasets are defined as follows:
- Byte values,
- EEPROM addresses and EEPROM datasets CANNOT overlap,
- EEPROM addresses must not overlap TABLE data,
- TABLE data has precedence from address 0x00 until the the end of TABLE all data,
- Strings must be expressed as ASCII byte value(s),
- Multiple elements on a single line separated by commas,
- Constants and calculations within the single line dataset entries are permitted,
- Decimal values are NOT supported,
- Access is via EPRread(), not supported by READTABLE().
- 18F devices must use even address for EEPROM location, and, 18F will pad (with 0x00) datasets to even number length. This
is MPASM constraint and therefore the compiler and assembler will isssue specific error messages for odd EEPROM locations.
Defining EEPROM datasets
Single data values
A single value on each line with in the dataset. The example dataset, shown below, has the data on different line in within the set.
Simple example: This creates an EEPROM dataset at the first EEPROM location, then, the values of 12, 24, … 72 are the consecutive values.
EEPROM EEDataSet 12 24 36 48 60 72 End EEPROM
Multiple data values of the same line
The following example creates the EEPROM dataset at EEPROM offset address of 0x10.
Multiple elements on a single line separated by commas. The example dataset, shown below, has the data separated by ,
and on different line in within the dataset.
EEPROM EEDataSource 0x10 12, 24, 36 48, 60, 72 End EEPROM
Data values as constants, and, with data transformation
Constants and calculations within the single line. The example dataset, shown below, uses a defined constant to multiple the data with the dataset.
#define calculation_constant 2 EEPROM EEDataSource 0x20 1 * calculation_constant 2 * calculation_constant 3 * calculation_constant 8 * calculation_constant 4 * calculation_constant 5 * calculation_constant End EEPROM
Data values as Strings
Strings can be defined. Strings are delimited by double quotes. The following examples show the methods.
Any ASCII characters between any two " " (double quotes) will be converted to dataset data. Also see ASCII escape codes.
A source string can be one string per line or comma separated strings, therefore, on the same line.
Example:
EEPROM Test_1 "ABCDEFGHIJ" End EEPROM
ASCII Escape code
Accepted escape strings are shown in the dataset below.
Escape sequence | Meaning |
---|---|
\a |
beep |
\b |
backspace |
\f |
formfeed |
\l or \n |
newline |
\r |
carriage return |
\t |
tab |
\0 |
Null value, equates to ASCII 0. Same as \&000 |
\&nnn |
ascii char in decimal |
\\ |
backslash |
\" |
double quote |
\' |
single quote |
Complete working example program
This example creates several EEPROM datasets. The example also create a lookup table. The EEPROM dataset are addressed with the additional parameter to ensure there is no EEPROM dataset overlap.
#chip 16F886 #option explicit #DEFINE USART_BAUD_RATE 9600 #DEFINE USART_TX_BLOCKING #DEFINE USART_DELAY OFF Dim EEdataaddress, myvar as Byte EEdataaddress = 2 Readtable TwoBytes,EEdataaddress,myVar HSerPrint myVar // *********************** EXAMPLE EE DATA ************************ // * THIS IS ONLY ACCESSIBLE VIA EPREAD or other EE read functions. /* Usage: EEProm EEPromBlockName [[,] OffSet Address ] OffSet address defaults to 0x00 if not stated. Addresses and datasets CANNOT overlap. Addresses must not overlap TABLE data. TABLE data has precendence from address 0x00 until the the end of TABLE data */ EEProm EEDataSet1 0x10 // Locate EE Data at address 3,2,1 End EEProm EEProm VersionData 0x20 // Locate EE Data at address " PWM2Laser " " Fabrice ENGEL " " Version 1.4 " " November 2023 " End EEProm EEProm EEDataSet2 0x0D // Locate EE Data at address 1,2,3 End EEProm EEProm EEDataSet 0X04 // Locate EE Data at address 1,2,3 End EEProm // ********************** EXAMPLE TABLE DATA BEING LOADED INTO EE BY THE COMIPILER // * THIS IS ONLY ACCESSIBLE VIA READTABLE Table TwoBytes STORE data // EE Data Address Allocated by compiler 0X55,0XAA,0X55 End Table
For more help, see EPRead, Creating EEProm data from a Lookup Table