Teensy 3.6 & Variables declaration to store in EEPROM area.

Status
Not open for further replies.

Driver55

New member
Hi guys,

I'm relatively at the beginning with the use of Teensy3.6, and I'm trying to migrate some existing applications.
Currently I have the following difficulty, which appears trivial, but stop me from moving forward in my work:

1.) how to declare a variable/struct that must be saved in the internal EEPROM ??

In previous developments with Atmel-Framework Environments for AVR products you will be able to use the "EEMEM" keyword.

example:

Code:
typedef struct
{
uint8_t a;
uint8_t b;
uint8_t c;
}defvalue_type;

defvalue_type EEMEM Varname = { 1,2,3 };

During the upload, the declared variables are thus transferred to the EEPROM area.

Currently I'm using the following tools:

1.) Arduino 1.8.1
2.) TeensyLoader 1.35

(Although I would as soon as possible switch to Visual Studio)

Can someone help me?
 
Last edited:
AFAIK, this way won't work for the 3.x Teensys. You'll have to include the EEPROM library, keep your struct in the (large enough) RAM and write or update it to the EEPROM by code if you want the data to be reboot persistent.
 
Thanks Theremingenieur,

I guess it depends on the uploading protocol of Teensyduino 1.35.
In the meantime I have integrated into the file "eeprom.h" the directive for the compiler
to allocate the variables defined with "EEMEM" in the EEPROM area.

So will generated at least the file "*.epp" to be transferred to the EEPROM of teensy 3.6.

Code:
// Driver55 Integration
// def EEMEM
// Attribute expression causing a variable to be allocated within the .eeprom section. 

#define EEMEM __attribute __ ((section ( ".eeprom")))

Unless I've lost any steps, I'm surprised that this directive was not included .
Now, however, the problem remains of how to transfer in an automatic way during the uploading of firmware, or alternatively, a possibility of manual transfer ..

Any suggestions ??
 
Last edited:
The idea of the EEPROM lib is not to write values or worse, allocate space for variables, into the eeprom during upload, but to allow to store and recall values only at runtime.

That's what I meant by hold your struct in the RAM (where it can be written and read 100 times quicker) and use the EEPROM library to backup it either periodically or event triggered from your code.
 
Status
Not open for further replies.
Back
Top