This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/MCU/MCU_REAL_FINAL/eeprom.h

36 lines
1.1 KiB
C
Raw Normal View History

#ifndef _EEPROM_H_
#define _EEPROM_H_
/*Declare SFR associated with the IAP */
sfr IAP_DATA = 0xE2; //Flash<73>Ĵ<EFBFBD><C4B4><EFBFBD>
sfr IAP_ADDRH = 0xE3; //Flash <20>ߵ<EFBFBD>ַ
sfr IAP_ADDRL = 0xE4; //Flash <20>͵<EFBFBD>ַ
sfr IAP_CMD = 0xE5; //Flash <20><><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
sfr IAP_TRIG = 0xE6; //Flash <20><><EFBFBD>ƴ<EFBFBD><C6B4><EFBFBD><EFBFBD><EFBFBD>
sfr IAP_CONTR = 0xE7; //Flash <20><><EFBFBD>ƼĴ<C6BC><C4B4><EFBFBD>
/*Define ISP/IAP/EEPROM command*/
#define CMD_IDLE 0 //<2F><><EFBFBD><EFBFBD>
#define CMD_READ 1 //<2F><>
#define CMD_PROGRAM 2 //д
#define CMD_ERASE 3 //<2F><><EFBFBD><EFBFBD>
/*Define ISP/IAP/EEPROM operation const for IAP_CONTR*/
//#define ENABLE_IAP 0x80 //if SYSCLK<40MHz
#define ENABLE_IAP 0x81 //if SYSCLK<20MHz
//#define ENABLE_IAP x82 //if SYSCLK<10MHz
//#define ENABLE_IAP 0x83 //if SYSCLK<5MHz
//Start address for STC89C58xx EEPROM
2022-06-07 06:46:17 +00:00
#define IAP_ADDRESS 0xF200
typedef unsigned char BYTE;
typedef unsigned int WORD;
void Delay(BYTE n);
void IapIdle();
BYTE IapReadByte(WORD addr);
void IapProgramByte(WORD addr, BYTE dat);
void IapEraseSector(WORD addr);
#endif