Using Kevin’s code, according to tests, either the write or the read is failing. The return from a read operation is 0.
void Process_Data_From_Master_uP(void)
{
static unsigned char i;
Getdata(&rxdata); /* Get fresh data from the master microprocessor. */
/* Remote Program Loading */
drt_prog_switch = !SW_PROG;
Default_Routine(); /* Optional. See below. */
Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
EEPROM_Write_Handler();
Putdata(&txdata); /* DO NOT CHANGE! */
}
/* EEPROM Address Mapping */
#define EEP_ARM_POT_STOWED_LOW 0x0000
#define EEP_ARM_POT_STOWED_HIGH 0x0001
ARM_POT_STOWED = EEPROM_Read(EEP_ARM_POT_STOWED_LOW);
ARM_POT_STOWED += (unsigned int)EEPROM_Read(EEP_ARM_POT_STOWED_HIGH) << 8;
if(need_eep_update)
{
if(EEPROM_Queue_Free_Space() > 2)
{
printf("Updating EEPROM
");
printf("ARM_POT_STOWED = %i
", ARM_POT_STOWED);
EEPROM_Write(EEP_ARM_POT_STOWED_LOW, (byte)(ARM_POT_STOWED & 256));
EEPROM_Write(EEP_ARM_POT_STOWED_HIGH, (byte)(ARM_POT_STOWED / 256));
need_eep_update = 0;
}
}
Yes, ARM_POT_STOWED is a variable, not a #define, and it is not zero on the write. It is a two byte variable, thus, I split it up into two bytes for the EEPROM.
Need an answer as soon as possible. Thanks in advance.