cancel
Showing results for 
Search instead for 
Did you mean: 

change endian type FATFs

scholar
Associate II
Posted on March 26, 2015 at 11:58

i am a beginner in microcontroller coding i was playing with fatFS recently, i wrote a loop to continuously write 0x1234578    in hex form in file but from file i am geting output as

 78 56 34 12 78 56 34 12

i know that this is because of endian mismatch and there is a statement

#define __REV                             __rev 

in file core_cmInstr.h but i didn't know how and where to use it directly to change endian type

i am writing data in a variable named as buffer before writing to file on card

following is the loop i use

for (kk = 0; kk < size; kk++ )

{

buffer[kk] = 0x12345678;

}

 should i use __rev  in loop ? when i try to use it by asm('__rev') keil returns error.. plz help
1 REPLY 1
Posted on March 26, 2015 at 13:31

for (kk = 0; kk < size; kk++ )
{
buffer[kk] = __rev(0x12345678); 
}

You could always write the buffer in a byte wise fashion too.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..