4 Replies Latest reply on Dec 28, 2016 8:09 AM by user_11721473

    Emulated EEPROM requires actual initialization.

    user_11721473

      Spent a lot of time trying to understand where is the BUG.
      The reason is, if you do not really fill EEPROM array with definite values, it does not work, returning CYRET_BAD_PARAM.
      Say, if you declare EEPROM array as 
          static const uint8 CYCODE eepromArray[8];
      you will not be able to perform EEPROM_Write.

         

      You have to fill it with any values.
          static const uint8 CYCODE eepromArray[8]= {0, 0, 0, 0, 0, 0, 0, 0};

         

      then it will work.

         


      IMHO, it MUST be mentioned in the manual. 

         

      Tested only with PSoC 4.

         

      Example to test:

         

      int main()
      {
          uint8 t[8]={1,2,3,4,5,6,7,8};       
          cystatus status;   
          static const uint8 CYCODE eepromArray[8]= {8, 7, 6, 5, 4, 3, 2, 0};
          static const uint8 CYCODE eepromArray1[8]= {0, 0, 0, 0, 0, 0, 0, 0};
          static const uint8 CYCODE eepromArray2[8];

         

          Em_EEPROM_Start();
                
          status = Em_EEPROM_Write(t, eepromArray,8u);              // OK
          if (CYRET_SUCCESS != status){
              SW_Tx_UART_PutString("Em EEPROM error\n\r");   
          }   
          status = Em_EEPROM_Write(t, eepromArray1,8u);           // OK
          if (CYRET_SUCCESS != status){
              SW_Tx_UART_PutString("Em1 EEPROM error\n\r");   
          }     
          status = Em_EEPROM_Write(t, eepromArray2,8u);       
          if (CYRET_SUCCESS != status){
              SW_Tx_UART_PutString("Em2 EEPROM error\n\r");   // you'll get this error 
          }       
          while(1);
      }