Jump to content
43oh

Recommended Posts

I am trying to use the I2C communication using SDA(1)-SCL(1) and also by using SDA(2)-SCL(2) with library wire.h, but it is not working. wire1 or wire2 are also not available, how to use the I2C with SDA(2)-SCL(2) using  energia.

Following is the program tried for the for SDA(0)-SCL(0)  but it is also not working.

 

#include <Wire.h>
 
void setup() {
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
}
 
void loop() {
  Wire.requestFrom(8, 6);    // request 6 bytes from slave device #8
 
  while (Wire.available()) { // slave may send less than requested
    char c = Wire.read(); // receive a byte as character
    Serial.print©;         // print the character
  }
 
  delay(500);
}
 
Thanks in advance.
Link to post
Share on other sites

You can use Wire.setModule(x) by using 0 to 3 to select the port. By default it is on PN4/PN5. The current implementation does not support multiple instances of the Wire library.

Also make sure that you have pullups on the SDA/SCL line.

    {GPIO_PB2_I2C0SCL, GPIO_PB3_I2C0SDA},
    {GPIO_PN5_I2C2SCL, GPIO_PN4_I2C2SDA},
    {GPIO_PA2_I2C8SCL, GPIO_PA3_I2C8SDA},
    {GPIO_PD0_I2C7SCL, GPIO_PD1_I2C7SDA}
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...