4 Replies Latest reply on Jun 1, 2015 3:44 PM by Intel_Peter

    Intel Edison SPI CS pin issue

    Nicobari

      Hi,

      I am trying to read data from a sensor using SPI protocol. I have a simple code for that which is shown below. I am using Eclipse and uploading and running code on Intel Edison using OTG USB port.

       

      #include "mraa.hpp"
      
      #include <iostream>
      #include <unistd.h>
      
      
      int main() {
      
          mraa::Spi* IMU = new mraa::Spi(0);
          if (IMU->mode(mraa::SPI_MODE3) != MRAA_SUCCESS
                  || IMU->bitPerWord(16) != MRAA_SUCCESS
                  || IMU->frequency(1000000) != MRAA_SUCCESS) {
      
              std::cerr << "Can't set SPI 0" << std::endl;
              return MRAA_ERROR_UNSPECIFIED;
          }
      
          static uint8_t SPI_command[] = { 0x00, 0x12 };
      
          uint8_t* rcvBuf;
      
          while (1) {
      
              rcvBuf=IMU->write(SPI_command, 2);
              usleep(200);
      
              printf("%i %i \n",rcvBuf[0],rcvBuf[1]);
      
          }
      
          return MRAA_SUCCESS;
      }
      
      

       

      So as it can be seen from the code I am creating a SPI object, setting the bitPerWord to 16, setting the SPI_MODE3 and frequency to 1MHz. Doing all this doesn't give me any error. Now when I run the code and hook up my SPI_CS0 to a signal analyzer I don't see any pulses whereas I can see pulses on SPI_CLK and SPI_TX channel. So it doesn't make sense to me that the SPI is initialized and the SPI_CLK and SPI_TX chanel are active but SPI_CS0 is not active. What can be issue here (I checked the physical connection and I have continuity between Edison SPI_CS0 pin and the pin where sensors is attached). Also how else I can control SPI_CS0 pin. I will appreciate any help in this matter. Thank you.

       

      TM