/*
********************************************************************************************************************
Description: Testing a program to write internal eeprom data and read it back and displayed
mcu = Atmel AT89S8253 at Vdd=3.3 matching CM60010ACT6 1.8" color LCD module
Date: 4 Nov 2006 ongoing
Programmer: John Leung
Internet: [url]www.TechToys.com.hk[/url]
********************************************************************************************************************
*/
#include <REG8253.H>
#include <absacc.h>
unsigned char buf[32];
void ieem_WrByte(unsigned int adr, unsigned char val);
unsigned char ieem_RdByte(unsigned int adr);
unsigned char k;
void main (void)
{
ieem_WrByte(0x0700, 0x39);
k=ieem_RdByte(0x0700);
while(1){
;
}
}
/*
********************************************************************************************************************
* Write a single byte to internal eeprom at the address adr
********************************************************************************************************************
*/
void ieem_WrByte(unsigned int adr, unsigned char val)
{
EECON|= (EEMEN_ | EEMWE_); // EEPROM Access Enable. Redirects MOVX | EEPROM Write Enable
XBYTE[adr] = val; // write value
while ((EECON & RDY_) == 0) // wait until value programmed by monitoring the RDY_ flag in EECON register
// RDY_=0 means programming is still in progress
EECON &= ~(EEMWE_ | EEMEN_);// disable EEPROM and write strobe
}
/*
********************************************************************************************************************
* Read a single byte from internal eeprom specified by the address adr
********************************************************************************************************************
*/
unsigned char ieem_RdByte (unsigned int adr)
{
unsigned char v;
EECON |= EEMEN_; // enable EEPROM
v = XBYTE[adr];
EECON &= ~EEMEN_; // disable EEPROM
return (v);
}
/*
********************************************************************************************************************
* Write a page of 32 bytes from buffer buf to internal eeprom with starting address specified by adr_start
* Page write at 4ms instead of 4*32ms! A much faster mode for writing large chuck of data
********************************************************************************************************************
*/
void ieem_WrPage(unsigned int adr_start, unsigned char *buf)
{
//TBD
}