ZVC read a specific byte in P-Flash memory

cancel
Showing results for 
Search instead for 
Did you mean: 

ZVC read a specific byte in P-Flash memory

276 Views
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

Tags (2)
0 Kudos
1 Reply

249 Views
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 Kudos