/*****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
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
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
Previous article:STC89C51RC_EEPROM header file
Next article:Data high and low bit exchange program
Recommended ReadingLatest update time:2024-11-15 11:37
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- ASML predicts that its revenue in 2030 will exceed 457 billion yuan! Gross profit margin 56-60%
- Download address of Arteli technical resources
- MSP430F249 external interrupt P1.3 port
- It was despised the day before yesterday, it was debunked yesterday, and today... it was blocked.
- New uses for old phones (1) - Basic method
- How to make the Type-C mobile phone fast charge and listen to music at the same time? Try adding a Type-C PD chip
- GD32E231 DIY Competition - Indoor Environment Monitoring Terminal
- The problem of large fluctuation in stm32ADC conversion output
- Please tell me if this function is achievable.
- Section 3 LMR33630-Q1: An excellent choice for primary power supply
- Disassemble the Xiyangyang Bluetooth speaker into eight pieces