S32K148 EEPROM write double type when data error?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S32K148 EEPROM write double type when data error?

1,930件の閲覧回数
kongdetao
Contributor III

Now start the EEPROM function on the S32K148 EVB board, then write double type data to the area and report an error.

 

The system has entered the default ISR. Has any of the experts encountered this problem?

 

code show as below:

{

Double doubleW = 2.1f;

...

EEE_WriteDouble(0x14000000, doubleW);

}

Int EEE_WriteDouble(uint32_t globalAddr, double val)
{

  While ((FTFC-> FSTAT & FTFC_FSTAT_CCIF_MASK) == 0){}

  *((double *)globalAddr) = val;
  Return 0;
}

ラベル(1)
タグ(3)
4 返答(返信)

1,743件の閲覧回数
jiri_kral
NXP Employee
NXP Employee

Hi, 

you can write to EEEPROM data up to 4 bytes. If you have more bytes (array or double value in your case) you need to split your data into 4 byte parts. Here is example how to write byte array:

int EEE_Write_ByteArray(char* source,char* target,unsigned int size)
{
   unsigned int cycles=size/4;
   unsigned int remain=size%4;
   unsigned int offset=0;
   for (int i=0;i<cycles;i++)
   {
      while ((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0){}
      *(int*)(target+offset)=*(int*)(source+offset);
      offset+=4;
   }

   for (int i=0;i<remain;i++)
   {
      while ((FTFC->FSTAT & FTFC_FSTAT_CCIF_MASK) == 0){}
      *(target+offset)=*(char*)(source+offset);
      offset+=1;
   }

   return 0;
}

Jiri

1,743件の閲覧回数
kongdetao
Contributor III

Thanks very much!!

Can you give an example for writing double type?

0 件の賞賛
返信

1,743件の閲覧回数
jiri_kral
NXP Employee
NXP Employee

Hi, 

you can use function for ByteArray write mentioned above: 

double YourDoubleValue=3.141592


EEE_Write_ByteArray((char*)(&YourDoubleValue),(char*)&YourDoubleTarget,8);

Or feel free to write your own function. Don't forget that YourDoubleTarget should be located in EEERAM section. 

Jiri

1,743件の閲覧回数
kongdetao
Contributor III

Thanks very much!

Fixed the Issue!!

0 件の賞賛
返信