6 Replies Latest reply on Mar 27, 2015 2:21 PM by AshishD

    EDISON GEN 2 I2C  not working with SEEED Motor Driver

    hemantt

      Hi,

      WE are trying to use I2C on Edison GEN2 work with I2C and with

      Here is the Motor Driver

      http://www.seeedstudio.com/depot/Grove-I2C-Motor-Driver-p-907.html

      This is my code in c  using mraa library.

      We need to send 4 bytes to Motor driver address-> command> value1->value2 based on its specification.

       

      Problem:

      The arduino code sample given by seed  works fine but equivalent C version does not work. And we have been told by few people that since clock speed of Edison and SEED Motor Driver is not same the data we are sending over I2C, Motor Driver can not read it.


      We tried to changed frequency on Edison board to minimum but still it does not communicate with SEEED motor driver.

      Question:

      Have any one made work I2C on Edison work with SEEED Motor Driver ?


      #define MAX_BUFFER_LENGTH 3

      #define HMC5883L_I2C_ADDR 0x0f

       

      int

      main(int argc, char** argv)

      {

          mraa_init();

          float direction = 0;

          int16_t x = 0, y = 0, z = 0;

          uint8_t rx_tx_buf[MAX_BUFFER_LENGTH];

          uint8_t direction_buf[MAX_BUFFER_LENGTH];

          printf(" starting \n");

          //! [Interesting]

          mraa_i2c_context i2c;

          i2c = mraa_i2c_init(1);

          int i =0;

       

          mraa_i2c_frequency(i2c,MRAA_I2C_STD);//

          sleep(5);

          /*

           * */

       

          while (i< 100){

            mraa_i2c_address(i2c, 0x0f);

        rx_tx_buf[0] = 0x82;

        rx_tx_buf[1] = 120;

        rx_tx_buf[2] = 128;

        mraa_i2c_write(i2c, rx_tx_buf, 3);

       

        //! [Interesting]

         usleep(10*1000);

       

         // set direction

       

            mraa_i2c_address(i2c, 0x0f); // E0

            direction_buf[0] = 0xAA;

           direction_buf[1] = 0b1010;

           direction_buf[2] = 0x01;

        mraa_i2c_write(i2c, direction_buf, 3);

       

        sleep(2);

       

        ++i;

          }

       

          mraa_i2c_stop(i2c);

      }