output_error &= ~(1<<chan);\r
}\r
\r
- if(to >= -1) {settings_changed = 3;}\r
+ if(to >= -1) {settings_changed |= 4;}\r
\r
uint8_t en1 = ((output_enable & 1) && !(output_error & 1))?0:1;\r
uint8_t en2 = ((output_enable & 2) && !(output_error & 2))?0:1;\r
limit[rxbuf[2]] = lim;\r
}\r
send_answer_hex(limit[rxbuf[2]]); \r
- settings_changed = rxbuf[2]+1; \r
+ settings_changed |= rxbuf[2]+1; \r
}\r
else {\r
forward_msg(7);\r
\r
} \r
\r
+#define EEPROM_DIS() while(EECR & (1<<EEPE)); EEARL = 0\r
+\r
void eeprom_write(uint8_t addr, uint8_t data){\r
while(EECR & (1<<EEPE));\r
EECR = (0<<EEPM0);\r
\r
\r
while(1) {\r
- if (settings_changed == 1) {\r
- settings_changed = 0;\r
- eeprom_write(0x10,limit[0]&0xFF);\r
- eeprom_write(0x11,(limit[0]>>8)&0xFF);\r
- }\r
- if (settings_changed == 2) {\r
- settings_changed = 0;\r
- eeprom_write(0x12,limit[1]&0xFF);\r
- eeprom_write(0x13,(limit[1]>>8)&0xFF);\r
- }\r
- if (settings_changed == 3) {\r
- settings_changed = 0;\r
- eeprom_write(0x14,output_enable);\r
- }\r
+ _delay_ms(3000); \r
+ if(settings_changed != 0) {\r
+ if (settings_changed & 1) {\r
+ settings_changed &= ~1;\r
+ eeprom_write(0x10,limit[0]&0xFF);\r
+ eeprom_write(0x11,(limit[0]>>8)&0xFF);\r
+ }\r
+ if (settings_changed & 2) {\r
+ settings_changed &= ~2;\r
+ eeprom_write(0x12,limit[1]&0xFF);\r
+ eeprom_write(0x13,(limit[1]>>8)&0xFF);\r
+ }\r
+ if (settings_changed & 4) {\r
+ settings_changed &= ~4;\r
+ eeprom_write(0x14,output_enable);\r
+ }\r
+ EEPROM_DIS();\r
+ }\r
}\r
}
\ No newline at end of file