Hi,
I am developing a boot-loader on MC9S12XE family with Classic CodeWarrior, I want to add a descriptor for the application code, and it should contain an address which is application code '_EntryPoint' (i.e. the address store in application's reset vector), my problem is how to allocate the '_EntryPoint' banked address to a uint32_t integer?
It is an example of my problem, if I use the type 'tIsrFunc' to allocate '_EntryPoint' is OK but 16 bit value, e.g. 0x1234U.
If I cast '_EntryPoint' to a uint32_t, the value will be shift left four bits, e.g. 0x00123400UL.
How do I cast a backed function address to uint32_t without shifted left four bits?
typedef void (*near tIsrFunc)(void);
typedef struct APP_TRY_ADDR_S
{
tIsrFunc fptr_near;
uint32_t fptr_far;
}APP_TRY_ADDR_T;
const APP_TRY_ADDR_T m_TryAddr =
{
&_EntryPoint, /* it is OK, but 16 bit only */
(uint32_t)&_EntryPoint, /* it is wrong, the value shifted left four bits */
};
hi Snaku,
I ever made sample code of far pointer to banked data address. see attached.
i think the method is similar for pointer to banked code address.
can this help?
Have a great day,
Zhang Jun
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Zhang Jun,
Sorry for my late reply, I try to change my example code with (unsign long * far) casting, but the result still shifted left four bits, 24 bits only, below is my test code.
#pragma CODE_SEG __NEAR_SEG NON_BANKED
#pragma NO_FRAME
#pragma NO_EXIT
void _EntryPoint(void)
{
...
}
#pragma CODE_SEG DEFAULT
typedef struct APP_TRY_ADDR_S
{
tIsrFunc fptr_near;
unsigned long * __far fptr_far;
}APP_TRY_ADDR_T;
const APP_TRY_ADDR_T m_app_try_addr
{
&_EntryPoint, /* result is 0x4046 */
(unsigned long * __far)&_EntryPoint, /* result is 0x404600, not 0x00004046 */
};
Should I use logical paged address like this page? Then I can jump/call to application start address easier.
And I don't want to use CONV_FAR_FUN_TO_DATA_PTR or CONV_FAR_DATA_TO_FUN_PTR macro which introduced in "S12(X) Build Tools Reference Manual".
Thanks for your support,
Snaku