Какая-то фигня с разрешением записи - через раз. Каждый второй раз не могу установить DUL Storing setup 1 ... OK!
Storing setup 2 ... error 1
Storing statistic ... OK!
0: Exit
Choice: 9
Storing setup 1 ... error 1
Storing setup 2 ... OK!
Storing statistic ... error 1
0: Exit
Choice: 9
Storing setup 1 ... OK!
Storing setup 2 ... error 1
Storing statistic ... OK!
//====================EEPROM========================
#define DATA_RASS_KEY1 ((uint8_t)0xAE)
#define DATA_RASS_KEY2 ((uint8_t)0x56)
#define UNLOCK_EEPROM() do { FLASH_DUKR = DATA_RASS_KEY1; FLASH_DUKR = DATA_RASS_KEY2;} while (0);
#define GET_EEPROM_UNLOCKED() (FLASH_IAPSR_DUL)
#define LOCK_EEPROM() FLASH_IAPSR_DUL=0
char WriteEepromBlockFromAddress(void* addr)
{
__disable_interrupt();
UNLOCK_EEPROM();
if (!GET_EEPROM_UNLOCKED())
{ __enable_interrupt();
return eepLOCKED;
}
block_erase(addr);
block_write(eeprom_block_buffer, addr);
LOCK_EEPROM();
if (GET_EEPROM_UNLOCKED())
{ __enable_interrupt();
return eepUNLOCKED;
}
__enable_interrupt();
return eepNO_ERROR;
}