My sketch uses nRF24L01, Ethernet shield with SD card on the SPI bus, each having it's own SS (4 SD, 10 Ethernet, 8 nRF24L01).
I use Arduino libraries ( SD, Ethernet) and Mirf library to drive these devices. Each is device is running fine, doing it's job....
BUT, since I added the nRF24L01 device, I noticed a slow down in my transferts from/to Ethernet and SD card...
Each operation takes twice the time it took before this module... I looked inside the Mirf library and seen the "SPI.setClockDivider(SPI_2XCLOCK_MASK);" line.
My question are :
is it possible that this line cut SPI performance down to half ?
2 is it possible to change this setting ?
in case of negative answer to 2), is it possible to have a second SPI bus ?
in case of positive answer to 3), how could I do ?
Is there another answer to my performance problem
Thanks for your answer
Pierre
is it possible that this line cut SPI performance down to half ?
Yes, it's even quite probable that it cuts down even more. This is because
#define SPI_2XCLOCK_MASK 0x01 // SPI2X = bit 0 on SPSR
and the correct constant with the same value is
#define SPI_CLOCK_DIV16 0x01
So the SPI bus is running with 1MHz instead of 4MHz.
2 is it possible to change this setting ?
Yes, but not in the nRF24L01 library but you can change it back to the default value of SPI_CLOCK_DIV4 just before and call to the Ethernet or SD libraries. If you increase the speed in the nRF24L01 library you might get a too fast speed for the device and it won't operate anymore or be at least less reliable.
in case of negative answer to 2), is it possible to have a second SPI bus ?
Not in hardware (on Arduinos).
in case of positive answer to 3), how could I do ?
You could do it in software but this will be much slower, so this is probably no option for you.
SPI.setClockDivider(SPI_CLOCK_DIV4);
.........
do want I want.... And everything came as it was before !!!!!!!!!!!!!!!
..........
SPI.setClockDivider(SPI_CLOCK_DIV16);
Mirf library is cutting SPI clock by 4... and everything using SPI bus is slowed seriously, but this module is so cheap and so easy to use !!!!!!!!!