need help ?????????

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

need help ?????????

759件の閲覧回数
davidacosta
Contributor I

//***********************************

//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

}

ラベル(1)
タグ(1)
0 件の賞賛
返信
3 返答(返信)

609件の閲覧回数
StenS
Contributor III

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

0 件の賞賛
返信

609件の閲覧回数
trytohelp
NXP Employee
NXP Employee

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!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信

609件の閲覧回数
davidacosta
Contributor I

fixed with "FLASH_data[pt]=((byte*)FLASH_addr)[pt];"

mods please delete this thread

0 件の賞賛
返信