battosai30 / FRAM

3 stars 1 forks source link

problem with example #3

Open rozrabiak opened 1 year ago

rozrabiak commented 1 year ago

Hi, below code from example:

 fram.WriteInt(0,20,-30000);
 Serial.println(fram.ReadInt(0,20));

returns:

35536

On STM32f4. bye.

battosai30 commented 1 year ago

Hi,

Almost 10 years old code ^^'

So I guess it's caused by 8-bits vs 32 bits architecture. Arduino "int" type has not the same size if you use for example a UNO or an STM32 : UNO will allocate 16 bits and STM32 32 bits.

I modified the code to specify exactly the size needed. But be warned : I can't test it as I have not FRAM anymore. So don't hesitate to come back and tell me how it goes ;)