2022-05-27 05:30 AM
my read flash reading is bellowing:
unsigned short * pAddr = (unsigned short * )0x08004000;
unsigned short read_value=0;
for(int i=0;i<10;i++)
{
read_value = *(pAddr +i);
printf(.....,read_value );
}
---------------
I add read_value to watch window ,however, read_values are not corresponding to data in flash.
pAddr+i is 0x08004002 but not 0x08004001 in watch window when pAddr = 0x08004000 and i=1;
pAddr+i is 0x08004004 but not 0x08004002 when pAddr = 0x08004000 and i=2;
and the read_value =*(pAddr+i ) results in read_value wrong data.
Why pAddr+i is not expected ?
2022-05-27 07:48 AM
Not sure what the question is, and there's not enough information to unravel the riddle.
What I can tell you is that POINTERs advance by the size of the item they are referencing. The unsigned short in this example being 16-bits, and 2 bytes in size.
>>Why pAddr+i is not expected ?
You're expecting the wrong thing