This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Saving Integer on 8252, correct my code please.

void save_byte (int xaddr, unsigned char xchar)
// this function works fine
// this fuction writes xchar to eeprom at xaddr

void save_integer(unsigned int xintnum)
{
unsigned int msblsb;
unsigned char msb,lsb;
msblsb = xintnum & 0xff00;
msblsb = msblsb >> 8;
msb = msblsb & 0x00ff;
lsb = xintnum & 0x00ff;

save_byte (0x0000,msb);
save_byte (0x0001,msb);
}
// this function does not write to eeprom
// i put the same way in reading integer number, but it does'nt work either.

// please some one correct my code
// thank you in advance
// kurnia brahmana

Parents
  • A wild guess, try this

    void save_integer(unsigned int xintnum)
    {
    unsigned int msblsb;
    unsigned char msb,lsb;
      msblsb = xintnum & 0xff00;
      msblsb = msblsb >> 8;
      msb = (unsigned char)msblsb & 0x00ff;
      lsb = (unsigned char)xintnum & 0x00ff;
    
      save_byte (0x0000,msb);
      delay 10ms implement this some way
      save_byte (0x0001,msb);
    }
    either the typecasts or the delay could do it.

    // this function does not write to eeprom
    // i put the same way in reading integer number, but it does'nt work either.

    by what method have you verified that it is the write, not the read that is faulty?

    Erik

Reply
  • A wild guess, try this

    void save_integer(unsigned int xintnum)
    {
    unsigned int msblsb;
    unsigned char msb,lsb;
      msblsb = xintnum & 0xff00;
      msblsb = msblsb >> 8;
      msb = (unsigned char)msblsb & 0x00ff;
      lsb = (unsigned char)xintnum & 0x00ff;
    
      save_byte (0x0000,msb);
      delay 10ms implement this some way
      save_byte (0x0001,msb);
    }
    either the typecasts or the delay could do it.

    // this function does not write to eeprom
    // i put the same way in reading integer number, but it does'nt work either.

    by what method have you verified that it is the write, not the read that is faulty?

    Erik

Children