1 2 3 Previous Next 30 Replies Latest reply on Jan 23, 2016 12:10 PM by nekosan0

    Edison and mraa(node.js) can't communicate with MAA7455L correctly via SPI


      I tried to connect edison and MAA7455 via SPI with mraa(node.js).

      But in some data patterns, they were not able to communicate correctly.



      MAA7455 is a 3d-accelerometer sensor which communicates with SPI.


      When I tried a program (communicating via SPI with edison-arduino board, edison-environment), it works well, and nothing is wrong.

      But I tried the same logic program with mraa + node.js, it does't work well in some data patterns.



      When edison read the register of x-axis/ y-axis/ z-axis, edison can read back the data from MAA7455L correctly like this.


      send    : 0x06 << 1 , 0x00  (x-axis, dummy)

      recieve : 0x00      , 0x12  (dummy, x-axis data)


      ('0x06' : x-axis register)



      When edison write the mode-control-register, edison cannot read back the data.


      send    : 0x16 << 1 + 0x80 , 0x09 (mode-control-register + write-mode , work/stanby-bit data)

      resieve : 0x00             , 0x00 (dummy data, dummy data)

      send    : 0x16 << 1        , 0x00 (mode-control-register(read back) , dummy)

      resieve : 0x00             , 0x00 (can't read back '0x09', not released stanby-mode)


      ('0x16' is the number of control-register, '0x80' means write-mode)

      ('0x09' : work/standby-bit -> "work" )



      With node.js + mraa, it failed to write the control-register.



      But, at first I run the program in edison-arduino-environment, then run the program in node.js environment,  node.js program can read back the registers correctly, too. The control-register may have written correctly by edison-environment, so both "read back" and "write" may become OK.


      By the way, with python , I have got same result.



      As you know, SPI is a simple protocol which exchenges the data between master-device and slave-device at the same times.


      So there is essentially no difference between "sending a normal-data" and "sending a control-data". Both are only bit stream expression for SPI.



      The only difference may be MSB.

         * read back : MSB = '0' (---> works well)

         * writing   : MSB = '1' (---> not works)



      So I think mraa wrapper might cause the trouble. (when it convert "unsigned char" and "signed char")



      I wonder what is the difference between edison-arduino-environment and mraa.

      And how to avoid this.



      Any help would be appliciated.

      Thank you.

        1 2 3 Previous Next