2017-03-02 12:46 AM
Hello, Does any one STM8s EEPROM data memory read and write example.
2017-03-02 01:00 AM
void EEWriteU8(uint16_t address, uint8_t value)
{
// Check if the EEPROM is write-protected. If it is then unlock the EEPROM.
if (FLASH_IAPSR_bits.DUL == 0) {
FLASH_DUKR = 0xAE;
FLASH_DUKR = 0x56;
}
// Write the data to the EEPROM.
(*(uint8_t *) (0x4000 + address)) = value;
// Now write protect the EEPROM.
FLASH_IAPSR_bits.DUL = 0;
}
void EEWriteArray(uint16_t address, uint8_t *src, uint8_t count)
{
uint8_t i = 0;
uint8_t *EEAddress;
// Check if the EEPROM is write-protected. If it is then unlock the EEPROM.
if (FLASH_IAPSR_bits.DUL == 0) {
FLASH_DUKR = 0xAE;
FLASH_DUKR = 0x56;
}
// Write the data to the EEPROM.
EEAddress = (uint8_t *) (0x4000 + address); // EEPROM base address.
for (; i < count; i++) {
*EEAddress = src[i];
EEAddress++;
}
// Now write protect the EEPROM.
FLASH_IAPSR_bits.DUL = 0;
}
void EEReadArray(uint16_t address, uint8_t * dest, uint8_t count)
{
uint8_t i = 0;
// Write the data to the EEPROM.
uint8_t *EEAddress = (uint8_t *) (0x4000 + address); // EEPROM base address.
for (; i < count; i++) {
dest[i] = *EEAddress;
EEAddress++;
}
}
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
2017-03-02 01:17 AM
Try this
2019-03-02 03:56 AM
Can any one say how should I store counter value in eeprom so that if power is gone it will store tha value of counter?
Counter is a variable I am using for 5 digit 7 segment display
2024-01-10 07:22 AM
ADC WATCH DOG VOLTAGE LEVEL & INTERRUPT.
measure voltage in the one of the adc chanel & use adc low voltage level watchdog interrupt in the specified voltage