I am trying to use the SPI library to talk to a sensor, then use the SD library to write data to an SD card. However, I am having mucho problems. If anyone can shed any light on the topic, I'd appreciate it.
The sensor uses SPI mode 3, and the SD card uses SPI mode 0. I know we can use something like
to change the mode, but can we change back and forth throughout the code? I am running into problems with that (SD card errors and erroneous readings from the sensor).
Also, I tried to just change the chip selects to deselect the SD card
then send some data to the sensor
and switch back
However, after this when I try to write to the SD card, I get an error! Why would sending data on SPI cause problems when the chip select is not selected?
Even stranger, it does not cause an error on the SD card if I transfer all ones... 0xFF. Does this make any sense to anyone?