STC11F02E_EEPROM header file

Publisher:数字冒险Latest update time:2016-09-06 Source: eefocusKeywords:STC11F02E  EEPROM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
/*************************************************************/

/*****File Function : STC11F02E_EEPROM Read and Write *****/
/*****Program Author : ZhengWen(ClimberWin) *****/
/*****Compile Date : 2009/3/3 *****/
/*****Edition Info : V1.0 *****/
/*****************************************************************/
/*****Amend Date : 2009.3.3 *****/
/*****Modified content: Modify the read and write subroutines to make them more concise********/
/*****************************************************************/
#ifndef __STC11FXX_EEPROM_CLIMBERWIN__
#define __STC11FXX_EEPROM_CLIMBERWIN__
#define uchar unsigned char
#define uint unsigned int          
#include
/***********************************************************/

/*****STC11FXX Special Function Register Definition********/
sfr isp_wdt = 0xc1;
sfr isp_data = 0xc2;
sfr isp_addrh = 0xc3;
sfr isp_addrl = 0xc4;
sfr isp_cmd = 0xc5;
sfr isp_trig = 0xc6;
sfr isp_contr = 0xc7;
/*********************************************/

/***************STC11FXX 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 = 0x5a; //First send 0x5a and then send 0xa5 ISP/IAP trigger register, this is required every time
    isp_trig = 0xa5; //After sending 0xa5, 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
}
/***************************************************/


/***************STC11FXX_EEPROM byte write program****************************/

void STC89CXX_EEPROM_Char_Write(unsigned int Write_addr ,unsigned char Write_data )
{
      
        isp_data = Write_data ;
        isp_addrh = Write_addr/256; //Send high address
        isp_addrl = Write_addr%256; //Address low
        EA = 0; /* Disable interrupt*/
        isp_contr = 0x81;      
        isp_cmd = 2; //Send sector command
        isp_trig = 0x5a;;
        isp_trig = 0xa5;
        _nop_();
        _nop_();
        isp_contr = 0;              
        isp_cmd = 0;
        isp_trig = 0;
        isp_addrh = 0;
        isp_addrl = 0;        
       // EA = 1; /* Enable interrupt*/
   
}
/******************************************************************/

/***************STC11FXX_EEPROM byte reading program****************************/

STC89CXX_EEPROM_Char_Read(unsigned int Read_addr)
{
  
       
        isp_addrh = Read_addr/256; //Send high byte of address
        isp_addrl = Read_addr%256; //Send low byte of address (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 = 0x5a; //Send 0x5a first and then 0xb9 ISP/IAP trigger register, this is required every time
        isp_trig = 0xa5; //ISP/IAP is triggered and started immediately after sending 0xa5_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 from triggering by mistake
        isp_addrh = 0; //Address points to non-EEPROM address area to prevent misoperation
        isp_addrl = 0;        
      //EA = 1; /* Enable interrupt*/
        return(isp_data );
   

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

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

#endif

Keywords:STC11F02E  EEPROM Reference address:STC11F02E_EEPROM header file

Previous article:STC89C51RC_EEPROM header file
Next article:Data high and low bit exchange program

Recommended ReadingLatest update time:2024-11-15 11:37

MCU simulates I2C bus to read and write EEPROM (24CXX) program 1
The following is a simple read-write program that can be used to detect the circuit condition. The program and circuit are attached first, followed by instructions. Circuit: Note: I use the LEDs on port P2 to detect which step the circuit has reached. I think it is very clear at a glance. program: #include r
[Microcontroller]
MCU simulates I2C bus to read and write EEPROM (24CXX) program 1
Using STM32's FLASH to emulate EEPROM (F103) series
       The FLASH of STM32 is used to store the main program. In order to save costs, ST did not add EEPROM, but we need to use EEPROM in many occasions; however, the capacity of FLASH is still considerable, and we can use FLASH to simulate EEPROM.        According to the introduction in "STM32F10X Flash Programming"
[Microcontroller]
Using STM32's FLASH to emulate EEPROM (F103) series
I2C Serial Bus and Serial EEPROM Expansion
1. Composition and working principle of I2C serial bus The use of serial bus technology can greatly simplify the system's hardware design, reduce the system's size, and enhance reliability. Commonly used serial expansion buses include: I2C bus (Inter IC BUS), single bus, SPI (Serial Peripheral Interface) bus and Micro
[Microcontroller]
Shenzhou IV Study Notes (VI) I2C Interface EEPROM-Software and Hardware Implementation
EEPROM is also called electrically erasable programmable read-only memory. Data is not lost after power failure. It is widely used to save small amounts of data. Some enhanced 51 microcontrollers and AVRs have EEPROM integrated inside the chip. The development board uses the I2C interface ATMEL's 24C02 chip, which has
[Microcontroller]
Shenzhou IV Study Notes (VI) I2C Interface EEPROM-Software and Hardware Implementation
A PIC program to read and write internal EEPROM (c)
#include int i,j=1,k=1; void initial(void)                  //initialization   {     TRISB=0x00;                        //RB is output      EEDATA=0x00;                      //initialize data     EEADR=0x00;                        //initialize address   } void write_data(void)                  { for(i==1;i
[Microcontroller]
17.EEPROM (IIC bus)
Composition and working principle of IIC serial bus The use of serial bus technology can greatly simplify the hardware design of the system, reduce the size of the system, and improve reliability. At the same time, the system can be easily modified and expanded. Commonly used serial expansion buses include: IIC (Int
[Microcontroller]
17.EEPROM (IIC bus)
C51IO port simulates I2C bus to drive AT24C16 (EEPROM part)
/*  Name: C51IO port simulates I2C bus driver AT24C16  Note: EEPROM, that is, AT24C16 here, is a special form of FLASH memory, but its capacity is generally small. It is more suitable for storing small amounts of data. The communication interface of AT24C16 is standard I2C communication, that is, we need to operate
[Microcontroller]
24C02 (EEPROM) Byte Read and Write Program (ASM)
24C02 read and write timing in bytes Selective Read Timing .................24c02 byte read and write program (debugged )......................   ;/////////////////////////////////////////////////////// ;IIC communication between AT89C52 and AT24C02 ; control the digital tube to display 0-P ; AT24C02
[Microcontroller]
24C02 (EEPROM) Byte Read and Write Program (ASM)
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号