//***********************************
//unsigned int *FLASH_address_pointer; // after the includes
//***********************************
void READ_Flash(void) { // move 128 bytes from FLASH at 0xF800 to FLASH_data[pt]
byte pt;
byte tmp;
FLASH_address_pointer=0xF800+8 ; // +8 offset for test only
for(pt=0;pt<128;pt++)
{
tmp = (byte)(&FLASH_address_pointer[pt]); // why does FLASH_address_pointer inc by two ??????
FLASH_data[pt] = tmp ; // you can see it in disassemble
} // help COLDFIRE V1, code warrior V6.3
}
Since FLASH_address_pointer is a pointer to an integer (16-bits = 2 bytes) it means that FLASH_address_pointer[0] points to F808, FLASH_address_pointer[1] to the next integer = F80A, etc. If FLASH_adress_pointer would point to a char (8 bits = 1 byte), you would get an increment by one.
/Sten
Hi David,
If you've problem, can you please provide us more details ?
tmp displays a part of address of the FLASH_address_pointer which is 0xf808.
The FLASH_address_pointer is an unsigned int so coded on 4 bits.
Each time the pointer is incremented, 4 bit is added the memory address and you will have:
tmp = 8
tmp = 12
tmp = 16
...
According to the \CodeWarrior for Microcontrollers V6.3\Help\PDF\ColdFireV1_Build_Tools_Reference.pdf manual - page 190, we know:
bool/char is coded on 8 bits
short is coded on 16 bits
int if "4-Byte Integers is off" is coed on 16 bits
int if "4-Byte Integers is on" is coed on 32 bits
long is coded on 32 bits
long long is coded on 64 bits
Have a great day,
Pascal
Freescale Technical Support
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
fixed with "FLASH_data[pt]=((byte*)FLASH_addr)[pt];"
mods please delete this thread