Johnny Wall

mc9s12xdt256 - Eeprom local and global access

Discussion created by Johnny Wall on Oct 3, 2008
Latest reply on Oct 6, 2008 by CompilerGuru
I have been fighting access to my 4k eeprom on my latest project. The access is sporadic and often the values I write into the address space, do not return when uses pointers.

PRM Link

EEPROM        = READ_ONLY     0xF000 TO   0xFFFF;
//when I do this, nothing shows up in that space on a near pointer call. Yet I still can see it on 0x13F000

I usually call in this manor
cks_rom = ((short)*(short *far)(ram_base));
//where ram_base is 0x13F000

or
cks_rom = ((short)*(short *near)(ram_base));
//where ram_base is 0xF000

The first one works some of the time, the second one never will.

void EEPROM_WRITE(int dt0, int dt1, int addr)
{
  addr= (addr & 0x0FFF)/2;
 

  while(ESTAT_CBEIF==0); 
  if(ESTAT_PVIOL ==1) ESTAT_PVIOL=0;
  if(ESTAT_ACCERR ==1) ESTAT_ACCERR=0;
  EADDRHI = (byte)(addr>>8);
  EADDRLO = (byte)(addr & 0xFF); 
  EDATAHI = (byte)(dt0>>8);
  EDATALO = (byte)(dt0 & 0xFF);
  ECMD = 0x60;
  ESTAT_CBEIF =1;
  while(ESTAT_CBEIF==0);
  while(ESTAT_CCIF==0);

 
  addr+= 1;

  while(ESTAT_CBEIF==0); 
  if(ESTAT_PVIOL ==1) ESTAT_PVIOL=0;
  if(ESTAT_ACCERR ==1) ESTAT_ACCERR=0;
  EADDRHI = (byte)(addr>>8);
  EADDRLO = (byte)(addr & 0xFF); 
  EDATAHI = (byte)(dt1>>8);
  EDATALO = (byte)(dt1 & 0xFF);
  ECMD = 0x20;
  ESTAT_CBEIF =1;
  while(ESTAT_CBEIF==0);
  // EPROT_EPOPEN = 0;
 
}

I would love to make 16bit pointer calls to get read access in logical, things haven't worked out for me yet ...

Outcomes