Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   EEPROM Problem (http://www.chiefdelphi.com/forums/showthread.php?t=54592)

Jake M 19-02-2007 20:04

EEPROM Problem
 
Using Kevin's code, according to tests, either the write or the read is failing. The return from a read operation is 0.

Code:

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! */
 }

Code:

/* EEPROM Address Mapping */
#define EEP_ARM_POT_STOWED_LOW  0x0000
#define EEP_ARM_POT_STOWED_HIGH  0x0001

Code:

  ARM_POT_STOWED = EEPROM_Read(EEP_ARM_POT_STOWED_LOW);
  ARM_POT_STOWED += (unsigned int)EEPROM_Read(EEP_ARM_POT_STOWED_HIGH) << 8;

Code:

  if(need_eep_update)
  {
    if(EEPROM_Queue_Free_Space() > 2)
    {
      printf("Updating EEPROM\r\n");
      printf("ARM_POT_STOWED = %i\r\n", 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.


All times are GMT -5. The time now is 04:44.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi