3 Replies Latest reply on Jun 6, 2018 3:09 AM by Intel Corporation

    SPI : mraa_spi_write_buf function problem. Read data error in ECG signals using ADS1298.


      Hi, please, I need some help regarding the acquisition way using the SPI interface. I’m doing an ECG acquisition system using ADS1298 and a Intel Edison Arduino module. The scenario is the following:

      I am using the MRAA SPI library for reading data from an IC: ADS1298.

      The IC: ADS1298 sends a falling edge signal every time a data frame is available.

      The data frame has a size of 27 bytes = 9 words of 24 bits and this should be read completely

      in less than 4 milliseconds. The SPI frequency is set to 4MHz. I use GPIO Interrupt to know when to read

      My code is as follows.




                  mraa_gpio_write(cs, 0);


                  mraa_spi_transfer_buf(ads, trama_data, trama_rcv, 27); //read 27 bytes data frame and store in a trama_rcv buffer


                  mraa_gpio_write(cs, 1);




                      canal[i]=trama_rcv[3*i];                                   //separated data in 9 channels

                      canal[i]=(canal[i]<<8) | trama_rcv[3*i+1];    //separated data in 9 channels

                      canal[i]=(canal[i]<<8) | trama_rcv[3*i+2];   //separated data in 9 channels


                      if((canal[i]>=0x800000)&&(canal[i]<=0xFFFFFF)){canal[i]|=0xFF000000;} //Positive or Negative  

                      fcanal[i]=(float)canal[i]/0x7FFFFF; 0 to 1

                fcanal[i]=2.4*fcanal[i];  Vref=2.4




      The reading and writing of the registers of the ADS1298 is perfectly done but the problem occurs when reading the 27 bytes data frame because in some instants the acquired data are not correct. This problem is shown in the next image.



      In the image above, I print 2 Channel of the 27 bytes data frame. The red circles show the data error. Thanks in advance.