You are not logged in.
So i have an interesting issue i'm seeing in my code.
i declared two uint64_t value.
uint64_t store_serialnumber; //serial number i'm wrote to flash
uint64_t actual_serialnumber; //serial number i'm reading from registers
...
...
printf("store serial: %x", store_serialnumber);
printf("acutal serial: %x", actual_serialnumber);
if( store_serialnumber != actual_serialnumber)
{
printf(" Values do not match.\n store value %x, actual value %x\n", store_serialnumber, actual_serialnumber);
goto exit;
}
exit:
printf("store serial: %x", store_serialnumber);
printf("acutal serial: %x", actual_serialnumber);
The issue i'm seeing is in the first two printf the values are the same, 55803214, as expected. But then when I go to compare the two value expecting it to match, it goes to the error condition and exit, and that last printf shows the store_serialnumber as 55803214 but the actual value became 10001. I don't get it, there is nothing in between the first two printfs and the if conditional statement that could have changed the value. But then the last two printfs in the exit statement that i put for testing will print out the correct expected value 55803214 for both varviable. What is going on? this is a c program by the way.
Offline
Without all of the code, it's impossible to say. I'd suggest looking up the semantics of volatile variables vs. regular variables.
Offline
Do they show up as different if you print them as %llu instead of hex?
I haven't lost my mind; I have a tape back-up somewhere.
Twitter
Offline
I also think that printf( "%x" ) reads 32 bit values, but you put 64 bit values on the stack.
Offline
Oh yeah, use PRIx64 from inttypes.h to printf() a uint64_t.
Offline