I'm working on a V-USB project that shows up as a Keyboard using an ATmega328p. The USB part is working great (it's not my first V-USB project), but after I start the V-USB stack with usbInit()
, all calls to the SD card library fail. If I call the same functions before usbInit()
, everything works perfectly.
I use an Arduino clone called Diavolino, but without the Arduino/wiring framework. I have the USB connected to digital I/O 2 and 3, and the SD card to 10-13 (built-in SPI lines).
I looked through the SD card library and found no sign of it using any interrupts or registers other than SPxx
. I also grep
'd though the V-USB code, but it doesn't even touch the SPxx
registers.
The first sign of the problem was when the device disconnected when it was supposed to access the SD card. Then I put usbPoll()
and wdt_reset()
calls into all SD card handling loops, and found that in case of writing, the card waits forever for acknowledgement from the card after having sent the last two bytes (CRC-16).
The SD card library I use is sd_raw
by Roland Riegel.