Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
11/25/04 07:07
Read: times


 
#81885 - can't access internal EEPROM of 89S8252
Hi all
The code to access internal EEPROM of AT89S8252 does not seem to be working & I donot get the desired result of accessing the internal mempory of eeprom. e.g.i wish to put 3 bytes starting from adress 0x0200 but this program always writes bytes starting from adress 0x2000+ 0x0200 i.e at 2200. I have tried with other addresses & found that it always adds 0x2000 to whatever address i am giving.

I have set bit EEMWE & EEMEN in the WMCON register as you can see. i have enclosed my code.

#include <AT89S8252.H>
#include <absacc.h>

void main()
{
unsigned int addr = 0x30;
void write(unsigned int, int);
int read(unsigned int);
int a[] = {0x09, 0x06, 0x47, 0x40} ;
int i,j,value;
WMCON = 0x0A;
for(i = 0;i < 4; i++)
write(addr+i,a[i]);
for(i = 0;i < 4;i++)
{
value = read(addr+i);
P1 = value;
for(j = 0;j < 30000;j++);
P1 = 0xFF;
}
WMCON = 0x02;
}

void write(unsigned int add, int val)
{
WMCON |= 0X10;
XBYTE[add] = val;
while((WMCON & EERDY_) == 0);
WMCON &= ~EEMWE_;
}

int read(unsigned int add)
{
int val;
val = XBYTE[add];
while((WMCON & EERDY_) == 0);
return(val);
}

When i use Keil debug tool it seems to write correctly at the desired address without adding any base address.
My hardware is very simple & consists of primary microcontroiller circuit without any external devices connected to it.
Your help in this regard will be an obligation.

with regards
Vishal


List of 11 messages in thread
TopicAuthorDate
can't access internal EEPROM of 89S8252            01/01/70 00:00      
   change int to char            01/01/70 00:00      
   Evaluation limit?            01/01/70 00:00      
      doesn't work            01/01/70 00:00      
   change addr            01/01/70 00:00      
   One problem I had with 8252 eeprom...            01/01/70 00:00      
   Offset            01/01/70 00:00      
      reading through parallel programer            01/01/70 00:00      
         it should be so            01/01/70 00:00      
            it is so            01/01/70 00:00      
               thanks            01/01/70 00:00      

Back to Subject List