I am trying to integrate logging to an SD card in my project. I have tried both the DevicePrint and FileLogger libraries and have the same problem with either.
Basically, the problem is that after I call the function to write the card, I can no longer display on my led matrix.
Both the DevicePrint and FileLogger libraries use the mmc lib. to write to the card with SPI. For the matrix, I use the LedControl library which has it's own "soft" SPI. This means that I don't even have to share the clock, MOSI, and MISO pins between the two devices. (I started by sharing them and now I'm only sharing the MOSI pin and still have the same problem.)
I am using an ATmega328 and I checked SRAM with availableMemory() and I have over 600 bytes free.
Looking at the library sources, I see that LedControl::spiTransfer function simply uses digitalWrite for it's SPI. The mmc library uses the ports directly to get hardware SPI on pins D10-13.
To restate the problem, the LedControl library works fine until I write the card using either the DevicePrint or FileLogger. Then the card will write fine, but the led matrix quits working until I press reset.
What's odd is that the more "scary" stuff like I2C and external interrupts 0 & 1 continue to work after an SD write. Only the second "soft" SPI device quits working.
I suspect that the mmc lib might be leaving something in a weird state, but what its' doing is beyond me.
I write this with the fear it's too gnarly to answer, but I would sure appreciate any guidance or tips on how to isolate this problem. I'm really stumped!
Thank you, John