FieldsOfFire 0 Posted October 18, 2016 Share Posted October 18, 2016 Hi all, Is there a fundamental flaw(s) with the attached code. I know it isn't elegant :-). New to this and I'm trying to write the word ABCDh to address location 2004h of an RFID chip with serial EEPROM. The device address is Ah but bits b3-b1 allow for multiple devices on the same bus hence 0xA2. I'm using p1.7 = SDA and P1.6 = SCL and have the necessary pull-ups. Any help/pointers/advice appreciated whilst I still have some hair. Quote Link to post Share on other sites
FieldsOfFire 0 Posted October 18, 2016 Author Share Posted October 18, 2016 #include <Wire.h> void setup(){ Wire.begin(); // join i2c bus} byte val = 0xAB;byte val_1 = 0xCD;void loop(){ Wire.beginTransmission(0xA2); // transmit to device 0xA2 10100010 Wire.write(byte(0x20)); // sends address hi byte Wire.write(byte(0x04)); // sends address lo byte Wire.write(val); // sends value into memory Wire.write(val_1); // sends value into memory Wire.endTransmission(); // stop transmitting } Sorry, found the paste function. Quote Link to post Share on other sites
roadrunner84 466 Posted October 18, 2016 Share Posted October 18, 2016 First of all, I2C has this oddity of using 7 bit addresses. When representing 7 bits in an 8 bit byte, it's never clear where to add the extra zero bit.Your device address is 1001xxx But does this translate to 01010xxx or to 1010xxx0 try using 89h instead of A2h, it might just work. Next thing, when writing 16 bit values over an 8 bit bus, make sure you have thew byte order (also called endianness) correct. Does 00FFh 0000000011111111 translate to 00h, FFh 00000000 11111111 or to FFh, 00h 11111111 00000000 so you could try either (or read back both addresses). energia 1 Quote Link to post Share on other sites
energia 484 Posted October 18, 2016 Share Posted October 18, 2016 Which LaunchPad are you using for this? Quote Link to post Share on other sites
FieldsOfFire 0 Posted October 24, 2016 Author Share Posted October 24, 2016 First time I've been able to use this forum for a few days as all I've been getting is an error page. I'm using the 430G2553. I had a look on data and clock pins and they were just sat high. Thought I'd try the code on an Arduino and I had data and clock activity. Sorting the I2C address out form A2h to a 7 bit address which became 51h (cheers for the reminder roadrunner84) I was able to communicate over I2C to my device :-) Out of interest I tried an MSP430FR5969 with my bit of code and that worked fine too. It would seem it there's an issue when using the 2553. I do have another 2553 which I tried and still no joy. I'm using Energia 17 by the way as 18 wouldn't work for me! Quote Link to post Share on other sites
LiviuM 43 Posted October 24, 2016 Share Posted October 24, 2016 Maybe the solution in this topic will help you as well? Quote Link to post Share on other sites
FieldsOfFire 0 Posted October 24, 2016 Author Share Posted October 24, 2016 Thanks for the info LiviuM. This all gets a bit flakey for me and not what I need. I took advantage of the TI $10 CCS offer so I might go down that route. Quote Link to post Share on other sites
roadrunner84 466 Posted October 25, 2016 Share Posted October 25, 2016 I condensed the comment in the referral in the referral from @@LiviuM their post. It boils down to two things to check: Call Wire.setModule(0) just before Wire.begin() Remove the jumper for LED2 (P1.6) next to S2 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.