ZVC read a specific byte in P-Flash memory

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

ZVC read a specific byte in P-Flash memory

784件の閲覧回数
michael_90300
Contributor I

Hello All,

I have to change my micro from a S12G64 to a ZVC19.

In my program, I have a line to read a specific byte in the P-Flash.

The problem in S12G64, the address has been converted from Global Memory Address to Local Memory address, I am not sure I have to do the same thing ZVC...

In S12G64 my code was:

// Addr variable is Global address, for example 0x38010 for a byte in Page 0xE

#define GlobalToLocal(Address) (((Address) & 0x3FFFU) | (((Address) & 0x003FC000UL) << 2U) | 0x8000U)

unsigned char mybyte;

mybyte= *(unsigned char *far)(GlobalToLocal(Addr));

I would like to know if the Following code is right on ZVC:

// In prm, ROM is defined form 0xFD0000 to 0xFFFDFF

// I would like to read Global Address Addr = 0xFE0010

unsigned char mybyte;

mybyte= *(unsigned char *far)(Addr);

Thank you for your help

Best regards

タグ(2)
0 件の賞賛
返信
1 返信

757件の閲覧回数
lama
NXP TechSupport
NXP TechSupport

Hi,

there is a difference between MCUs from the memory space point of view. S12Z devices use 24bit linear space only. So for example:

 //.........................................
 // read the flash
 //.........................................

 for(addrl=0xFF8000UL; addrl<=0xFF8FFFUL; addrl+=2)
   {
     result = PFLASH_Read_Word(addrl);
   }

//==============================================================================
//PFLASH_Read_Byte
//==============================================================================
unsigned char PFLASH_Read_Byte(unsigned long int address)
{
  unsigned char data8;
  data8 = *(unsigned char *)address;
  return data8;
}

//==============================================================================
//PFLASH_Read_Word
//==============================================================================
unsigned int PFLASH_Read_Word(unsigned long int address)
{
  unsigned int data16;
  data16 = *(unsigned int *)address;
  return data16;
}


Best regards,

Ladislav

0 件の賞賛
返信