Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/10/07 18:39
Read: times


 
#141700 - Read it as single-byte variable array
Responding to: ???'s previous message
You get into trouble to read data from EEPROM into an array of two-byte variable. In the reading steps, your code distributes the data into high byte or low byte. It makes things complicate. And it is, unfortunately, useless.

When you consider how the bytes are ordered on this array, you'll find that you have to read out twice as much bytes simply, instead of reading them as separated two-byte variables. Therefore, you don't need to modify the original code as of the master reader sequence. Just read out twice bytes.

If you have any byte order problem on the two-byte variable, swap bytes after reading them out.

Hi, I mod'ed the smbus state machine to handle to a address greater than 255

Declare the data counter, SMB_DATA_LEN, as unsigned int, instead unsigned char. Then, you can handle more than 255 bytes.

case SMB_MTDB_ACK_28:
if (addrLowSendFlag)
{
    SMB0DAT = CHAR_ADDR_LOW;

    //Reset the flag to skip
    addrLowSendFlag = 0;
    break;
   // insert break here, not to continue to next 'if' when WRITE.
}

case SMB_MRADDACK_40:
STA =0;
if (i == SMB_DATA_LEN - 1)
   // 'i' starts from 0; when single byte transfer, SMB_DATA_LEN is 1

case SMB_MRDBACK_50:
   // recover the code to the original

case SMB_MRDBNACK_58:
   // recover the code to the original


Tsuneo

List of 6 messages in thread
TopicAuthorDate
silican labs SMBus and I2c problem f040            01/01/70 00:00      
   Something missing?            01/01/70 00:00      
      updated post            01/01/70 00:00      
         Read it as single-byte variable array            01/01/70 00:00      
   totally ambigous            01/01/70 00:00      
      now that you added f040 I suggest            01/01/70 00:00      

Back to Subject List