2 Replies Latest reply on Aug 12, 2015 8:54 AM by JPMontero_Intel

    Fixed delay between SPI Messages

    Curby

      Hi there,

       

      i have the problem (ok is not a problem yet, but could be one day..) that between every SPI transmitting - no matter what clock etc. - there is a waiting period of 10ms.

      When sending single bytes i have 10ms beweteen every byte. When sending buffer i have 10ms between every messages.

       

      Is it a configuration issue?

       

      my simple test code is the following:

       

      int main()
      {
          uint8_t data[] = { 'H', 'a', 'l', 'l', 'o'};
      
          mraa_init();
          spi = mraa_spi_init(1);
          mraa_spi_frequency (spi, 100000);
          mraa_spi_mode(spi, MRAA_SPI_MODE0);
          mraa_spi_lsbmode(spi, 0);
      
          while(1)
          {
              mraa_spi_write_buf(spi, data, 5);
          }
      
      
           return 0;
      }
      
      
      

       

      I hope someone can explain it to me

       

      Nils

        • 1. Re: Fixed delay between SPI Messages
          JPMontero_Intel

          Hi Curby

           

          I’ve tried your code with a couple of changes, as well as with an Arduino code and I also got the 10ms delay but not between every single byte, it has a random behavior. The signal works properly for about a second and then I see the 10ms space, but it is not periodic. Below are the codes I’ve tried.

           

          #include "mraa.h"
          #include <unistd.h>
          #include <stdint.h>
          
          
          int main()
          {
              uint8_t data[] = { 'H', 'a', 'l', 'l', 'o'};
          
              mraa_init();
            mraa_spi_context spi;
              spi = mraa_spi_init(1);
              mraa_spi_frequency (spi, 100000);
              mraa_spi_mode(spi, MRAA_SPI_MODE0);
              mraa_spi_lsbmode(spi, 0);
          
              while(1)
              {
                  mraa_spi_write_buf(spi, data, 5);
              }
            return 0;
          }
          
          
          
          

           

           

          #include <SPI.h>
          uint8_t data[] = { 'H', 'a', 'l', 'l', 'o'};
          
          
          void setup() {
            SPI.begin(); //Sets by default mode=SPI_MODE0, bitOrder=MSBFIRST, clkDiv=SPI_CLOCK_DIV4
            SPI.setClockSpeed(SPI_CLOCK_100K);
          }
          
          
          void loop() {
            SPI.transferBuffer(data, 0, 5);
            SPI.end();
          }
          
          
          
          

           

           

          We will run some more tests to get a better understanding of it. We will contact you back as soon as we get more details.

           

          Regards,
          JPMontero_Intel

          • 2. Re: Fixed delay between SPI Messages
            JPMontero_Intel

            Hi Curby,

             

            We continued investigating about this issue and we found out this is a known issue with the SPI driver.

             

            Regards,
            JPMontero_Intel