Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Teensy 4.1 E2END value for maximum emulated EEPROM

  1. #1

    Teensy 4.1 E2END value for maximum emulated EEPROM

    The file teensy4/avr/eeprom.h defines E2END which specifies how much emulated EEPROM is available:

    Code:
    #if defined(ARDUINO_TEENSY40)
    #define E2END 0x437
    #elif defined(ARDUINO_TEENSY41)
    #define E2END 0x10BB
    #endif
    In this earlier post @Branan said that on Teensy 4.0 the value of E2END can be increased up to a maximum of 0xEC6, giving 3783 bytes of EEPROM with reduced wear levelling:

    https://forum.pjrc.com/threads/57377...l=1#post214566

    I couldn't quite understand how he arrives at this figure; there's a test in avr/cores/teensy4/eeprom.c:

    Code:
    #if E2END > (255*FLASH_SECTORS-1)
    #error "E2END is set larger than the maximum possible EEPROM size"
    #endif
    but that calculation gives a maximum of 255 x 15 - 1 or 3824 bytes, which is 41 more.

    My question is: what is the largest value I can set E2END to on the Teensy 4.1 to get the maximum contiguous EEPROM?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,764
    Teensy 4.1 has 63 sectors reserved for EEPROM emulation. So if you're willing to go with minimal wear leveling, you can set it to 0x3EC0, giving 16065 bytes of storage.

  3. #3
    Quote Originally Posted by PaulStoffregen View Post
    Teensy 4.1 has 63 sectors reserved for EEPROM emulation. So if you're willing to go with minimal wear leveling, you can set it to 0x3EC0, giving 16065 bytes of storage.
    Thanks - I see that's 255 x 63 - 1.

    So on Teensy 4.0, why isn't the maximum 255 x 15 - 1 or 0xEF0 rather than the value 0xEC6 recommended by @Branan?

    Thanks, David

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •