1 2 Previous Next 18 Replies Latest reply on Feb 2, 2017 3:12 PM by Intel Corporation

    Mraa SPI code causing a 'segmentation fault (core dumped)' ?

    conor100

      Hi,

       

      Could somebody explain why this SPI transfer creates a 'segmentation fault (core dumped)' error when running on the Joule?

       

      Thanks

       

      #include "mraa.hpp"
      #include <unistd.h>
      #include <stdint.h>
      
      
      int main(int argc, char** argv) {
        
        mraa_spi_context spi;
        spi = mraa_spi_init(0);
        printf("Hello, SPI initialised\n");
        uint8_t data[] = { 0x00, 100 };
        uint8_t* recv;
        
        while (1) {
          int i;
          for (i = 90; i < 130; i++) {
            data[1] = i;
            recv = mraa_spi_write_buf(spi, data, 2);
            printf("Writing -%i", i);
         printf("RECIVED-%i-%i\n", recv[0], recv[1]);
            usleep(100000);
        }
      }
      }
      
        1 2 Previous Next