Home > other >  Excuse me, ladies and gentlemen, this eeprom52. H header file is officially or custom
Excuse me, ladies and gentlemen, this eeprom52. H header file is officially or custom

Time:09-20

# # ifndef _EEPROM52_H_
# define _EEPROM52_H_
#include

/* * * * * * * * STC89C51 sector distribution * * * * * * *
The first sector: 1000 h - 11 ff
The second sector, 1200 h - 13 ff
The third sector: 1400 h - 15 ff
The fourth sector: 1600 h - 17 ff
Five sectors: 1800 h - 19 ff
The sixth sector: 1 a00h - 1 BFF
Sector 7:1 c00h - 1 DFF
Eight sectors: 1 e00h - 1 FFF
* * * * * * * * * * * * * * * * */

/* * * * * * * * STC89C52 sector distribution * * * * * * *
The first sector: 2000 h - 21 ff
The second sector, 2200 h - 23 ff
The third sector: 2400 h - 25 ff
The fourth sector: 2600 h - 27 ff
Five sectors: 2800 h - 29 ff
Six sectors: a00h - 2 BFF
Sector 7:2 c00h - 2 DFF
Eight sectors: 2 e00h - 2 FFF
* * * * * * * * * * * * * * * * */


# define RdCommand 0 x01//define the ISP operation command
# define PrgCommand 0 x02
# define EraseCommand 0 x03
# define the Error 1
# define Ok 0
# define WaitTime 0 x01//define the CPU waiting time
SFR ISP_DATA=https://bbs.csdn.net/topics/0xe2;//register declaration
SFR ISP_ADDRH=0 xe3;
SFR ISP_ADDRL=0 xe4;
SFR ISP_CMD=0 xe5;
SFR ISP_TRIG=0 xe6;
SFR ISP_CONTR=0 xe7;

/*================open ISP, IAP function=================*/
Void ISP_IAP_enable (void)
{
EA=0;/* shut interrupt */
ISP_CONTR=ISP_CONTR & amp; 0 x18;/* */0001100
ISP_CONTR=ISP_CONTR | WaitTime;/* write hardware delay */
ISP_CONTR=ISP_CONTR | 0 x80; ISPEN=1/* */
}
/*===============closed ISP, IAP function==================*/
Void ISP_IAP_disable (void)
{
ISP_CONTR=ISP_CONTR & amp; 0 x7f;/* ISPEN=0 */
ISP_TRIG=0 x00;
EA=1;/* interrupt */
}
/*================public trigger code====================*/
Void ISPgoon (void)
{
ISP_IAP_enable (); *//* open ISP, IAP function
ISP_TRIG=0 x46;/* trigger ISP_IAP command byte 1 */
ISP_TRIG=0 xb9;/* trigger ISP_IAP command byte 2 */
_nop_ ();
}
/*====================byte read========================*/
Unsigned char byte_read (unsigned int byte_addr)
{
EA=0;
ISP_ADDRH=(unsigned char) (byte_addr & gt;> 8); Address assignment/* */
ISP_ADDRL=(unsigned char) (byte_addr & amp; 0 x00ff);
ISP_CMD=ISP_CMD & amp; 0 xf8;/* remove low three */
ISP_CMD=ISP_CMD | RdCommand;/* read write command */
ISPgoon ();/* trigger execution */
ISP_IAP_disable ();/* close your ISP, IAP functions */
EA=1;
Return (ISP_DATA);/* */return to read data
}
/*==================sector erase========================*/
Void SectorErase (unsigned int sector_addr)
{
Unsigned int iSectorAddr;
ISectorAddr=(sector_addr & amp; 0 xfe00);/* */sector address
ISP_ADDRH=(unsigned char) (iSectorAddr & gt;> 8);
ISP_ADDRL=0 x00;
ISP_CMD=ISP_CMD & amp; 0 xf8;/* empty low 3 */
ISP_CMD=ISP_CMD | EraseCommand;/* erase command 3 */
ISPgoon ();/* trigger execution */
ISP_IAP_disable ();/* close your ISP, IAP functions */
}
/*====================byte write========================*/
Void byte_write (unsigned int byte_addr, unsigned char original_data)
{
EA=0;
//SectorErase (byte_addr);
ISP_ADDRH=(unsigned char) (byte_addr & gt;> 8);/* address */
ISP_ADDRL=(unsigned char) (byte_addr & amp; 0 x00ff);
ISP_CMD=ISP_CMD & amp; 0 xf8;/* low qing three */
ISP_CMD=ISP_CMD | PrgCommand; Write command/* 2 */
ISP_DATA=https://bbs.csdn.net/topics/original_data; Write data/* to */
ISPgoon ();/* trigger execution */
ISP_IAP_disable ();/* closed */IAP function
EA=1;
}

#endif

CodePudding user response:

Should be the custom, on STC?

CodePudding user response:

reference 1/f, worldy response:
should be custom, on STC?

Ok, thank you
  • Related