Teensy 4 EEPROM vs Teensy 3.1

Manu

Well-known member
Hello,

I have to port some teensy 3.x code to teensy 4.x.

With Teensy 3.x I used to use EEPROMEX library (https://github.com/thijse/Arduino-EEPROMEx) which allow me to store many datas in EEPROM.

Teensy 4.x seem to don't behave the same as Teensy 3.x regarding EEPROM.

Is there a similar library that can operate with Teensy 4.x ?

Here are some code I use to use :

Code:
void initEEprom()
{
    EEPROM.updateByte(1, 1); // Durée tempo rotation écran en minutes
#if defined(FENIXECU)
    EEPROM.updateByte(2, 0);      // Type de calculateur (par défaut Megasquirt)
    EEPROM.updateLong(4, 500000); // Bus CAN 500kbps
    EEPROM.updateBit(24, 0, 0);   // Français + Pas de rotation
#endif
#if defined(MOD7R)
    EEPROM.updateByte(2, 3);       // Type de calculateur (par défaut Sybele)
    EEPROM.updateLong(4, 1000000); // Bus CAN 1Mbps
    EEPROM.updateBit(24, 0, 1);    // Anglais
#endif
#if defined(PPRACING)
    EEPROM.updateByte(2, 5);       // Type de calculateur (par défaut Nicolas Serre)
    EEPROM.updateLong(4, 1000000); // Bus CAN 1Mbps
    EEPROM.updateBit(24, 0, 0);    // Français
#endif
    EEPROM.updateByte(3, 1); // ZT Active
    EEPROM.updateByte(8, 0); // Vue 0 (Roulage)
    EEPROM.updateByte(9, 7);
    EEPROM.updateByte(10, 9);
    EEPROM.updateByte(11, 10);
    EEPROM.updateByte(12, 6); // Vue 1 (Réglage)
    EEPROM.updateByte(13, 4);
    EEPROM.updateByte(14, 3);
    EEPROM.updateByte(15, 9);
    EEPROM.updateByte(16, 0); // Vue 3 (Températures)
    EEPROM.updateByte(17, 1);
    EEPROM.updateByte(18, 2);
    EEPROM.updateByte(19, 3);
    EEPROM.updateByte(20, 6); // Vue 4 (Pressions)
    EEPROM.updateByte(21, 7);
    EEPROM.updateByte(22, 8);
    EEPROM.updateByte(23, 11);
    MiniMAxi_razEEPROM();
    EEPROM.updateByte(0, 170); // EEprom configurée
    return;
}

void MiniMAxi_razEEPROM()
{
    for (int i = FIRST_MINI_VALUE_ADRESS; i < (FIRST_MINI_VALUE_ADRESS + EEPROM_MIN_MAX_LENGTH); i = i + 4)
    {
        EEPROM.updateFloat(i, 0.);
    }
    EEPROM.updateFloat(25, 60.);   // Mini tMot
    EEPROM.updateFloat(33, 60.);   // Mini tAir
    EEPROM.updateFloat(41, 90.);   // Mini tOil
    EEPROM.updateFloat(49, 300.);  // Mini tEch
    EEPROM.updateFloat(57, 50.);   // Mini alphaPap
    EEPROM.updateFloat(81, 6.);    // Mini pOil
    EEPROM.updateFloat(89, 6.);    // Mini pEss
    EEPROM.updateFloat(97, 16.7);  // Mini AFR
    EEPROM.updateFloat(105, 20.);  // Mini Niveau Carburant
    EEPROM.updateFloat(113, 14.5); // Mini vBat
    EEPROM.updateByte(1023, 0);    // Rotation EEPROM = 0 (20 rotations maxi)
    EEPROM_Mini_StartAdress = FIRST_MINI_VALUE_ADRESS;
    EEPROM_Maxi_StartAdress = FIRST_MINI_VALUE_ADRESS + 4;
    rotationEEPROM          = 0;
    return;
}

Thank you,
Manu
 
Have you tried it on Teensy 4 yet?

Quick look inside the code seems to be using the avrlibc eeprom functions, which we support on all Teensy models.

There could of course be some sort of problem I didn't see with only a quick look at the code. But if you haven't tried it, please do so. It doesn't seem to have any code specific to Teensy at all. Odds are pretty good it will just work, because the API it's using is supported the same for any Teensy.
 
Have you tried it on Teensy 4 yet?

Quick look inside the code seems to be using the avrlibc eeprom functions, which we support on all Teensy models.

There could of course be some sort of problem I didn't see with only a quick look at the code. But if you haven't tried it, please do so. It doesn't seem to have any code specific to Teensy at all. Odds are pretty good it will just work, because the API it's using is supported the same for any Teensy.
I think the problem is in cores\teensy4\avr_functions.h

A lot of the helper functions are commented out.
Looks like that portion of the file has not been updated since your first add of the Teensy4 cores back like 7 years ago.
 
Back
Top