Trouble using built in SPI lib

Hello everyone.

I have some code that was developed in the Arduino IDE which I have moved into Platformio.
The code sends data to shift registers which then drive displays. The code has worked for years when compiled using Arduino IDE.
I can compile and load the code in Platformio but I am seeing some differences.
Firstly, in the Arduino IDE, SPI.transfer is ‘destructive’ in as much as it will fill the array that is being written out with any data that is read in. On Platformio it appears that the SPI.transfer is NOT destructive. I proved this to myself by setting the array to all 0’s after the SPI.transfer and all was good.
The second ‘issue’ is that, during the display update, I can see elements that would usually be blank glow slightly (and very briefly) as the rest of the display is updated. I suspect that this is the data being shifted through the registers though am not so sure.
I do not see this when compiling with Arduino IDE - maybe it’s a timing thing?
Is there a method whereby I can NOT use the ‘built in’ SPI lib in Platformio but use some other one?
If so - does anyone have any recommendations? I have not yet worked out what is bundled with the Arduino IDE.

  • Richard

I think I have got around the problem (though I still don’t understand the differences I was seeing in what was the same code).
Essentially I needed to increase the transfer speed.
I was using:
SPI.setFrequency(100000);

I am now using:
SPI.setFrequency( 10000000L);

I still do not know why it worked fine when using Arduino IDE - perhaps it was defaulting to something higher and my specified value was too low?

Regardless, everything is now fine.

  • Richard