AnsweredAssumed Answered

__far and s12 global address

Question asked by ZF Fu on May 9, 2019
Latest reply on May 13, 2019 by ZF Fu

Dear NXPers,

I create a project on MC9S12G** with BANKED model.

There is a structual type variable  EMS_infoMapS, its address in page is 0x8000, global address is 0x04000, logic address is ox18000(page=1).The following picture is S12 memory map.

Picture1. s12 memory map

The following code is about the address of EMS_infoMapS,

#pragma CONST_SEG DEFAULT
extern EMS_CTRLMAP_TYPE * __far EMS_infoMapSP; 

 

#pragma CONST_SEG MAP1_ROM
volatile const EMS_CTRLMAP_TYPE EMS_infoMapS=
{

...

}

 

PLACEMENT

...

MAP1_ROM 
INTO PAGE_01;

...

END

 

And .map file show address allocation results.

MODULE: -- Map.c.o --
- PROCEDURES:
- VARIABLES:
EMS_infoMapSP 1674 3 3 47 .data
EMS_infoMapS 18000 2EA4 11940 2 MAP1_ROM

 

Then, I do the following operation,

void ADC_GetAnagValue1(void)
{
DisableInterrupts;
ADC_tClntUW = IntpoCur_u16((uint16 * __far) &ADC_tClntUW_CUR,ADC_tClntRsUW);
EnableInterrupts;
}

 

const uint16 *__far MAPAddr_u16;

uint16 IntpoCur_u16(const uint16 * __far MAPAddr,uint16 X)
{

MAPAddr_u16_reverse = MAPAddr;

...

}

 

I debug, and find MAPAddr is wrong.

picture2. wrong address

 

I dont konw why MAPAddr is but 0x801200 not 0x401200, it is a wrong result.

How can i get ADC_tClntUW_CUR's true global address?

Looking forward to your reply.

Thanks.

Outcomes