Cómo escribir el programa de lectura y escritura EEPROM para stm8s y qué pasos de configuración se requieren
#define EEPMASS1 0xAE //Clave de contraseña 1
#define EEPMASS2 0x56 //Clave de contraseña 2
#define EEPADDR 0x4000 //dirección eep inicial< / p>
void eeprom_read(U16 u16Addr, U8 *pdatas, U8 len)
{
U8 *eep=(U8 *)u16Addr; U8 j;
for(j=0; j { pdatas[j]=eep[j]; > } } void eep_word_write(U16 u16Addr, U8 *pdatas, U8 len) { U8 * eep=(U8*)u16Addr; U8 j; FLASH_DUKR=EEPMASS1; //Bloquear 1 tecla FLASH_DUKR=EEPMASS2; while(!(FLASH_IAPSR&0x08)); //Esperando que el descifrado esté listo DISABLE_MAC_INTERRUPTS(); FLASH_CR2 |= 0x40; p> p> FLASH_NCR2 &= ~0x40; //Establecer programación de palabras for(j=0; j { eep[j] = pdatas[j]; } while(!(FLASH_IAPSR&0x04)); FLASH_IAPSR &=0xf7; el programa eeprom ENABLE_MAC_INTERRUPTS() }