Proper Way to store/read EEPROM value

What's the proper way to store/read EEPROM value.

I have declared my offset in EEPROM.h as LALALA 1048 which is available.

I'm using HAL::eprSetByte( LALALA, 1 ) and HAL::eprGetByte( LALALA  ) to write and read.

Do i have to do something more ?

Comments

  • Check M206 implementation. It also updates the eeprom checksum otherwise it would delete eeprom on next bootup.
  • I'm using this command GCode::executeFString(PSTR("M206 T0 P1048 S1"));

    Type byte
    Position 1048
    Value 1

    And when i'm trying to read by this way :
    if( HAL::eprGetByte(EPR_BED_CALIBRATION_OK) == 0 ) { ... }

    no luck. It never jumps into if statement

    My target is to start a calibration wizard only on the first boot, and then never again.


  • The above command sets value to 1 so it will not jump into your if.
    For debugging add in







    void EEPROM::writeSettings()

    a write for your position. Then you see the value and can set it to 0 with eeprom editor.

  • Misunderstanding, Sorry.

     if( HAL::eprGetByte(1048) == 0 ) { ... } is checked at the first boot before the wizard takes place. And it has to be true.

    As the wizard is finished i do GCode::executeFString(PSTR("M206 T0 P1048 S1")); to mark that first boot wizard has been completed.

    But on the very first boot it never jumps into the above if as it's supposed. All unused bytes in EEprom are zero right ?
  • No, unused bytes are not zero, that is only your assumption. At least I think that since new float values have inf value and I think 0 would not match to inf. But I might be wrong. Thats why I suggested adding the write so you know and can modify before sending printer. Same goes with language selector wizard which starts if set to 255 or 254, not sure about that exactly.
  • Where do you initialize eeprom values before first boot ?
  • The loader detects that eeprom mode or checksum mismatches and reinitalizes it.
Sign In or Register to comment.