/*****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
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
{
isp_da
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_da
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
return(Read_isp_da
}
/**************************************************************/
/*******************************************************************************/
#endif
Previous article:STC12C12C5410 PCA Application
Next article:STC11F02E_EEPROM header file
Recommended ReadingLatest update time:2024-11-15 13:45
- 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
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- AVR assembler, paid help
- Allegro software design has been updated with the latest patch, but why can't I do 3D simulation?
- EEWORLD University ---- Embedded Linux Development Introduction Video
- What is a smart WiFi module? What are the types and functions of wireless router gateway control modules?
- Reasons for choosing 4-20mA for flow meter
- I want to ask why this motor cannot start? The voltage from B+ to B- is normal, but after starting, the voltage from B+ to M- jumps and the motor vibrates.
- Summary of equivalent circuits of common electronic components
- Comparison of several MicroPython IDEs
- [RVB2601 Creative Application Development] @fxyc87 RVB2601-Snake Game
- Qinheng USB PD and other fast charging protocol power receiving chip CH224 evaluation - the first data study and unboxing