I2C problems on GR-Sakura

hope someone can help me out here.

i have tried to use an I2C bus through the Wire implementation, but nothing works at all.

How to enable the I2C and send data on the bus?

  • Did you try this sample code?  I hope you are using Web compiler and the corresponding version of library.

    tool-cloud2.renesas.com/.../library_wire.html

  • In reply to Kaz:

    Thanks a lot for your answer Kaz.

    I have tried following code using both Web compiler and the E2Studio stand alone version.

    Also I tried both Sketch 2.06 and 1.08 with same result.

    I expect to see some SCL signals while running the code on pins IO6/7 but all pins just low level.

    Tried to use pull up resistors but still no SCL clk appear on any pins of the board.

    Then I just tried to use wire instead of wire6 but still no signals on pins AD6/AD5.

    What do I miss here?

    By using a genuine Arduino UNO board it works!

    One last thing. I did comment out Wire6.endTransmission(); to avoid the software to get stucked in this function.

    Thanks for your support

    /* GR-SAKURA Sketch Template V2.05 */

    #include <Arduino.h>

    #include <wire.h>

    #include <utilities.h>

    void I2C_Gyro();

    #define INTERVAL 100

    void setup()

    {

       pinMode(PIN_LED0,OUTPUT);

       pinMode(PIN_LED1,OUTPUT);

       pinMode(PIN_LED2,OUTPUT);

       pinMode(PIN_LED3,OUTPUT);

       TwoWire(6);

       Wire6.begin(); // join i2c bus (address optional for master) (Pin 6 & 7)

    }

    void loop()

    {

       digitalWrite(PIN_LED0, 1);

       delay(INTERVAL);

       digitalWrite(PIN_LED1, 1);

       delay(INTERVAL);

       digitalWrite(PIN_LED2, 1);

       delay(INTERVAL);

       digitalWrite(PIN_LED3, 1);

       delay(INTERVAL);

       digitalWrite(PIN_LED0, 0);

       delay(INTERVAL);

       digitalWrite(PIN_LED1, 0);

       delay(INTERVAL);

       digitalWrite(PIN_LED2, 0);

       delay(INTERVAL);

       digitalWrite(PIN_LED3, 0);

       delay(INTERVAL);

       analogWrite(1, 128);

       analogWrite(0, 128);

       I2C_Gyro();

    }

    void I2C_Gyro()

    {

          Wire6.beginTransmission(63); // transmit to device #4

          Wire6.write("x is ");        // sends five bytes

          Wire6.write("a");            // sends one byte

          //Wire6.endTransmission();    // stop transmitting

          delay(500);

    }

  • In reply to Johnny Hansen:

    You need pull-up resisters use the wire.

    Try this:

    /* GR-SAKURA Sketch Template V2.06 */

    #include <Arduino.h>
    #include "wire.h"
    #define INTERVAL 100
    void setup() {

       pinMode(PIN_LED0,OUTPUT);

       pinMode(PIN_LED1,OUTPUT);
       pinMode(PIN_LED2,OUTPUT);
       pinMode(PIN_LED3,OUTPUT);
       Wire6.begin();
    }

    void loop(){

       digitalWrite(PIN_LED0, 1);
       digitalWrite(PIN_LED1, 1);
       digitalWrite(PIN_LED2, 1);
       digitalWrite(PIN_LED3, 1);


       Wire6.beginTransmission(63);
       Wire6.write("5");
       Wire6.endTransmission(63);

       digitalWrite(PIN_LED0, 0);

       digitalWrite(PIN_LED1, 0);
       digitalWrite(PIN_LED2, 0);
       digitalWrite(PIN_LED3, 0);
       delay(1000);

    }

    Then I got the following clock output:

  • In reply to Kaz:

    Great and thanks a lot for your support. Now it finally works and I get a nice clk too.

    Strange.......looks like the order of the code lines made the different.

    Anyway we are back on track now:-)