In SX Microcontrollers, SX/B Compiler and SX-Key Tool, JonnyMac wrote: I found a 24LC16B in my stash and updated the program from the help file so that MEM_OUT does not return until the write-cycle is complete. Here's the update: [code]' Use: MEM_OUT address, value ' -- writes 'value' to 24LC16B location at 'address' ' -- "address" is a word (two bytes required) ' -- "value" is a byte MEM_OUT: tmpW1 = __WPARAM12 ' copy address tmpB1 = __PARAM3 ' copy value I2CSTART SDA tmpW1_MSB = tmpW1_MSB & $03 ' get block value tmpW1_MSB = tmpW1_MSB << 1 tmpW1_MSB = tmpW1_MSB | SlaveID ' create control byte tmpW1_MSB.0 = 0 ' set RW bit for write I2CSEND SDA, tmpW1_MSB ' send slave ID I2CSEND SDA, tmpW1_LSB ' send word address I2CSEND SDA, tmpB1 ' send data byte I2CSTOP SDA ' finish DO ' let write cycle finish I2CSTART SDA I2CSEND SDA, tmpW1_MSB, ackBit ' resend slave ID LOOP UNTIL ackBit = Ack RETURN[/code] You could use conditional compilation to disable the write-delay, and if you're going to be using I2C is a large application its a good idea to encapsulate the core I2C commands in custom subroutines and functions; I2C has a timing element to is and, therefore, generates a bit of code. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=205777#m205826 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)