This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I2c not working with energia. Below is the code attached. Please help
Master Reader
#include <Wire.h>
void setup()
{
Wire.setModule(0);
Wire.begin(); // join i2c bus (address optional for master)
Serial.begin(9600); // start serial for output
}
void loop()
{
Wire.requestFrom(2, 6); // request 6 bytes from slave device #2
while(Wire.available()) // slave may send less than requested
{
char c = Wire.read(); // receive a byte as character
Serial.print(c); // print the character
}
delay(500);
}
Slave Sender
.
#include <Wire.h>
void setup()
{
Wire.setModule(0);
Wire.begin(2); // join i2c bus with address #2
Wire.onRequest(requestEvent); // register event
}
void loop()
{
delay(100);
}
// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent()
{
Wire.write("hello "); // respond with message of 6 bytes
// as expected by master
}
Hello,
For Energia-related posts, please post them to the 43oh forum at https://forum.43oh.com/. For general I2C debugging tips, please take a look at Section 5 in the Solutions to Common eUSCI and USCI Serial Communication Issues on MSP430™ MCUs app note.
Regards,
James
Have you:
1. Put pull up resistors on I2C SDA and SCL lines
2. Looked at these lines with a scope and/or I2C Bus analyzer?
Attached is (a complicated) slide showing MSP430 connecting to BQ device and doing a I2C Write/Read (Got a whole TI training video in the the works). I can dig up the Energia code if you need it.
I haven't used the ET version. but one thing that tripped me up on MSP-EXP430G2 was that SCL is also connected to the Green LED. And thus the LED circuit was messing up the I2C voltage levels. Just had to remove the LED jumper.
Please see below.
**Attention** This is a public forum