decomposition long number to byte and recomposition With FRAM
There is one very obvious error in your code: You are writing the long
number LSB (least significant byte) first: the LSB goes at address 3 of
the FRAM, while the MSB (most significant byte) goes at address 6. You
reconstruct the number with

longRicomposto = ((longPt4 &lt;&lt; 0) + (longPt3 &lt;&lt; 8) + (longPt2 &lt;&lt; 16) + (longPt1 &lt;&lt; 24));


which puts longPt1 (contents of address 3) as the most significant
byte. Thus you are swapping all the bytes around.

Then there is a more subtle error. longPt1 is a byte. According to the
C++ promotion rules, it is implicitly promoted to int before any
arithmetic or logical operation. But since an int is 16-bits, you are
shifting all the bits out when you do longPt1 &lt;&lt; 24. You should cast
the numbers to a 32-bit type before shifting, as follows:



long longRicomposto = (uint32_t) longPt1 &lt;&lt;  0
                    | (uint32_t) longPt2 &lt;&lt;  8
                    | (uint32_t) longPt3 &lt;&lt; 16
                    | (uint32_t) longPt4 &lt;&lt; 24;


Note that I am casting to an unsigned type. Shifting a 1 into the bit
sign of an integer is undefined behavior in C++: the shift must be done
with an unsigned type, then, if needed, cast to a signed type.