3 Replies Latest reply on Feb 25, 2014 3:07 PM by LDiego_Intel

    CANbus shield performance issue - SPI related ?

    eontap

      I have an application currently running on UNO and MEGA using the CANdiy shield CANbus shield. On those devices I can process around 100 CAN messages per second (8 bytes of data). On Galileo the best I have been able to get is 30 messages per second. Performance was even lower (15 msg/sec) until I changed the SPICS pin on the shield to pin #3 and then  tried the OPUTPUT_FAST setup  described by deckard026354 in this board. I then tried fastGpioDigitalWrite but did not see any performance change beyond the initial gain.

       

      Is there any SPI performance numbers I can use as a guideline to find how much upside performance can I get by tweaking other parameters and considering the transferbuffer SPI extension on the Galileo SPI library ? I am not very familiar with SPI so any suggestions on what to tweak (clock, divider, etc)  will be greatly appreciated. The CANbus library I am using is from Seedstudio: http://www.seeedstudio.com/wiki/images/5/55/CAN_BUS_Shield.zip

       

      Anyone in the Intel Galileo team looking at shield specific issues I can contact ? I will be happy to send a shield if that helps with the diagnostic and resolution.

       

      Thanks in advance for any suggestions.

        • 1. Re: CANbus shield performance issue - SPI related ?

          Hello Eontap

           

          I have noticed some posts related to the SPI, but not related to this shield, I will take a look to the information I have,  I will let you know as soon as I find something about it.

           

          Regards,

          LDiego.

          • 2. Re: CANbus shield performance issue - SPI related ?
            dferyance

            Go with using transferbuffer. I don't know anything about the shield you are using, but from my own experience with SPI this is important. I modified an Arduino SPI LCD library from making individual SPI calls to buffering the data and making just a few transferbuffer calls. This had a huge impact in SPI performance. No other performance-related tweak I have tried made as much of an impact. Of course this depends on how many SPI calls are being made and if they can be buffered.

             

            Each SPI call has to go into the kernel to perform the operation. I expect it is doing some form of IO scheduling and waiting as well. This has a significant performance overhead. The fewer of these transitions the better.

             

            One other thing to try: the Arduino SPI library doesn't support the 25mhz SPI that the chip supports. Try modifying the clockdivider logic in the SPI library. It doesn't actually set a clock divider but translates the Uno's clockdivider settings to a hz speed that gets passed into the kernel driver. If the chip you are talking to supports it, you should be able to up the frequency.

            • 3. Re: CANbus shield performance issue - SPI related ?

              Hi eontap,

               

              These are the speed references that we have in our FAQ section  https://communities.intel.com/message/207619

               

              Q: What is the maximum rate at which GPIO output pins can be updated?

              The GPIO output pins on Intel® Galileo are provided by an I2C Port Expander that is running at standard mode (100 kHz). Each I2C request to update a GPIO requires approximately 2ms. In addition to software overhead, this restricts the frequency achievable on the GPIO outputs to approximately 230 Hz.

              Q: What is the maximum SPI clock speed supported?

              The default setting for the SPI clock on Intel® Galileo is 4 MHz, the same as Arduino Uno. Similarly, the SPI clock can be varied from 125 kHz to 8 MHz using SPI.setClockDivider(). The Intel® Quark SoC X1000 supports SPI clock frequencies up to 25 MHz, but this support is not yet added in the Arduino IDE.

               

              My suggestion will be to use the pin 2 and 3 with fastGpioDigitalWriteDestructive mode as documented in the post https://communities.intel.com/thread/45267 , but please keep in mind that the SPI speed depends on the GPIO speed.

               

              Regards,

              LDiego.