STC89C51RC_EEPROM header file

Publisher:Serendipity22Latest update time:2016-09-06 Source: eefocusKeywords:STC89C51RC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
/************************************************************************************/

/*****File  Function :  STC89C51RC_EEPROM Read and Write *****/
/*****Program Author :  ZhengWen(ClimberWin)                       *****/
/*****Compile Date   :  2008/2                                                  *****/
/*****Edition Info   :  V1.0                                                        *****/
/*****Amend   Date   :                                                            *****/
/*****************************************************************************/
#ifndef __STC89C51RC_EEPROM_CLIMBERWIN__
#define __STC89C51RC_EEPROM_CLIMBERWIN__
#define uchar unsigned char
#define uint  unsigned int          
#include
/*******************************************************/

/*****STC89C51RC special function register definition********/
sfr isp_wdt = 0xE1;
sfr isp_data = 0xE2;
sfr isp_addrh = 0xE3;
sfr isp_addrl = 0xE4;
sfr isp_cmd = 0xE5;
sfr isp_trig = 0xE6;
sfr isp_contr = 0xE7;
/*********************************************/

/***************STC89CXX_EEPROM sector erase program****************************/
void STC89CXX_EEPROM_Erase(unsigned char t_addr)
{
    isp_addrh = t_addr; //It is not necessary that any byte in the sector is the sector address, no need for the first address, the MCU will handle it by itself
    isp_addrl = 0;
    EA = 0; //Disable interrupt
    isp_contr = 0x81;      
    isp_cmd = 3; //Sector erase, to make a byte empty, must erase 1 sector
    isp_trig = 0x46; //First send 0x46 and then send 0xb9 ISP/IAP trigger register, this is required every time
    isp_trig = 0xb9; //After sending 0xb9, ISP/IAP is immediately triggered to start
    _nop_(); _nop_
    ();
    isp_contr = 0;   
    isp_cmd = 0;
    isp_trig = 0;
    isp_addrh = 0;
    isp_addrl = 0;
    EA = 1; // Enable interrupt
}
/***************************************************/


/***************STC89CXX_EEPROM byte write program*****************************/
void STC89CXX_EEPROM_Char_Write(unsigned char Write_addr_h,unsigned char Write_addr_l ,unsigned char Write_da ta)
{
      
        isp_da ta = Write_da ta;
        isp_addrh = Write_addr_h; //Send address high bit
        isp_addrl = Write_addr_l; //Address low bit
        EA = 0; /* Disable interrupt*/
        isp_contr = 0x81;      
        isp_cmd = 2; //Send sector command
        isp_trig = 0x46;
        isp_trig = 0xb9;
        _nop_();
        _nop_();
        isp_contr = 0;              
        isp_cmd = 0;
        isp_trig = 0;
        isp_addrh = 0;
        isp_addrl = 0;        
        EA = 1; /* Enable interrupt*/
   
}
/******************************************************************/

/***************STC89CXX_EEPROM字节读程序*************************/
STC89CXX_EEPROM_Char_Read(unsigned char Read_addr_h,unsigned char Read_addr_l)
{
  
        unsigned char Read_isp_data;

        isp_addrh = Read_addr_h; //Send address high byte
        isp_addrl = Read_addr_l; //Send address low byte (starting from 0 to num-1)
        EA = 0; /* Disable interrupt*/
        isp_contr = 0x81; /*20M, is 0x80 orl 1 */
        isp_cmd = 1; // 1 means byte read
        isp_trig = 0x46; //Send 0x46 first and then 0xb9 ISP/IAP trigger register, this is required every time
        isp_trig = 0xb9; //After sending 0xb9, ISP/IAP is immediately triggered to start
        _nop_(); //No instruction
        _nop_(); //No instruction
        isp_contr = 0; //Disable ISP/IAP operation
        isp_cmd = 0; //Remove ISP/IAP command
        isp_trig = 0; //Prevent ISP/IAP Command false trigger
        isp_addrh = 0; //The address points to the non-EEPROM address area to prevent false operation
        isp_addrl = 0;        
        EA = 1; /* Open interrupt*/
        Read_isp_da ta=isp_da ta;
        return(Read_isp_da ta);
   

/**************************************************************/

/*******************************************************************************/

#endif

Keywords:STC89C51RC Reference address:STC89C51RC_EEPROM header file

Previous article:STC12C12C5410 PCA Application
Next article:STC11F02E_EEPROM header file

Recommended ReadingLatest update time:2024-11-15 13:45

stc12c5a60s2 eeprom program
  TC12C5A60S2/AD/PWM series microcontroller is a single clock/machine cycle (1T) microcontroller. It is a new generation of 8051 microcontroller with high speed/low power consumption/super anti-interference. The instruction code is fully compatible with traditional 8051, but it is 8-12 times faster. . Internally integ
[Microcontroller]
51 MCU——I2C bus EEPROM
We can save the data in EEPROM so that the data will not be lost when the power is off. Commonly used serial bus protocols: Currently, the commonly used serial buses for data transmission between microcomputers and peripherals are mainly I2C bus, SPI bus and SCI bus. I2C bus: Communicates in a synchronous serial 2
[Microcontroller]
51 MCU——I2C bus EEPROM
Interface and Programming of Serial EEPROM X24128 and AT89C51
X24128 is a CMOS serial communication EEPROM produced by XICor Corporation of the United States. The internal structure is a 16k byte 8-bit array. X24182 can connect 8 pieces in parallel on a 2-wire bus at the same time, and has software and hardware write protection functions. The highest address unit (FFFFH) in the
[Microcontroller]
Reading and writing of EEPROM inside STM32 microcontroller
The STM32L series MCU provides an EEPROM storage area, but in fact, its FLASH is also an EEPROM type, but there is an area that is opened up for EEPROM operation. The STM32L EEPROM service life is designed to be more than 100,000 erase and write times, and the capacity is 2K-4K, which is ideal for parameter storage of
[Microcontroller]
Functions and differences of Flash and EEPROM in microcontrollers
I have been crazy about various microcontrollers recently. I have been looking at AVR microcontrollers recently and found that in addition to FALSH and SRAM, there is also an on-chip EEPROM in the microcontroller. I have never encountered this thing before and it seems to be useless. I generally feel that the external
[Microcontroller]
89C51 EEPROM-IIC experiment ---- self-study notes
1. What is EEPROM EEPROM is an electrically erasable programmable read-only memory. EEPROM (Electrically Erasable Programmable read only memory) refers to electrically erasable programmable read only memory. It is a storage chip that does not lose data after power failure. EEPROM can erase existing information and r
[Microcontroller]
89C51 EEPROM-IIC experiment ---- self-study notes
PIC16F877A EEPROM Usage
unsigned char eeprom_read(unsigned char addr); void eeprom_write(unsigned char addr, unsigned char value); These two functions are PIC internal functions and can be called directly;   -----------------------------The following content is written by a blogger in Baidu space------- http://hi.baidu.com/wxg923/item/
[Microcontroller]
ATmega64 EEPROM Data Memory
EEPROM Data Memory ATmega64 contains 2K bytes of EEPROM data memory. It exists as an independent data space and can be read and written byte by byte. The life of EEPROM is at least 100,000 erase cycles. EEPROM access is determined by the address register, data register and control register. P281 “Memory Programming”
[Microcontroller]
ATmega64 EEPROM Data Memory
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号