How to predefine EEPROM on PIC16F/pic14?

Help
Lou Cyphre
2007-02-07
2013-03-12
  • Lou Cyphre

    Lou Cyphre - 2007-02-07

    Say that I have a structure/array, and I wish to predefine EEPROM content with it, which storage class/modifier should I use to declare it?

    I'm thinking of a case like this:
    ------------------------------------------------------------
    struct MyStruct {
      uint8_t   one;
      uint8_t   two;
      uint16_t  thousand;
    };

    /*EEPROM*/ struct MyStruct   s = { 1, 2, 1000 };
    ------------------------------------------------------------
    How should I define 's' above, to have it in section DEEPROM for linker?

    Lou

     
    • Raphael Neider

      Raphael Neider - 2007-03-09

      Does
          __code struct MyStruct s = { 1, 2, 1000 };
      do what you want?

      Regards,
      Raphael

       
    • AP2k

      AP2k - 2007-05-18

      This is what the assembler preprocessor directives to do this will look like:

      __asm
          org 0x2100
          DE        0xB2,0x03    ;Set the old sizes to maximum
      __endasm

      Note that this snippet is for a project of mine. What it does is effectively making an unsigned BIG endian short of 0x3B2 at the data EEPROM address of 0x00.

      I _think_ that this C code will work, but I havent tested it yet:  short at 0x2100 OldSize = 0xB903;

      Notice that data EEPROM starts at 0x2100. Program EEPROM starts at 0x0000.

      I will probably put in some macros in my port code:

      #define DEFINE_DATA_EEPROM(data,address) {
          __asm
                org 0x2100+_address
                DE _data
         __endasm}

      #define DEFINE_PROGRAM_EEPROM(data, address){
          __asm
                org _address
                DE _data
          __endasm}

      Hope this helps.

       
      • AP2k

        AP2k - 2007-05-18

        Oops, in those macros I think I might have messed up. The # sign might need to be added before the variables and thier underscores.

         

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks