/************ STM8S103 EEPROM read and write ******/
Keywords:STM8S103F2
Reference address:STM8S103F2 EEPROM read and write
/*Chip model: STM8S103F2PB6 */
/*Function description: STM8S103 EEPROM read and write */
/*Author: ClimberWin */
/*Written on: 2013.11.24 */
/*Function: STM8S103 EEPROM read and write */
/*Internal crystal oscillator */
/**********************************************/
#include
//Start at address 0x004000
//The first hardware key 0xAE
//Second hardware key 0x56
unsigned char EEPROM_Date;
void main(void)
{
unsigned char *EEPROM_address;
EEPROM_address = (unsigned char *) 0x4000; // Starting address of EEPROM
//First you need to unlock the EEPROM
while(1)
{
FLASH_DUKR = 0xAE; // Write the first key datasheet p44
FLASH_DUKR = 0x56; // Write the second key
if(FLASH_IAPSR_DUL==1)break;
}
//while(FLASH_IAPSR_DUL==0); //p54 DUL 0 write protection enabled, 1 disabled
*EEPROM_address = 0x01; // Write data to the specified address
while(FLASH_IAPSR_EOP==0); //EOP=1 write operation successful
EEPROM_Date= *EEPROM_address; // Read EEPROM data from the specified address
while(1);
}
Previous article:STM8S103 Unique ID Reader
Next article:STM8S103F---RGB LED color light strip
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like