SD card read/write with Arduino

Hi JB.

The line:

if (RES_OK == mmc::writeSectors(sector_buffer, sector, 1))

writes 1 sector's worth of data stored at sector_buffer in the arduino's SRAM to the specified sector on the card. Once this routine returns your data is stored. The line:

digitalWrite(13, (millis() / 1000) & 1)

has nothing to do with the workings of the program. It simply flashes the LED on port 13 to let you know all's done.

All reads and writes in uFat are 512 bytes. This is the size of a sector on the card. It would be possible to write a function that allows arbitrarily-sized writes but that would add to the size.

Do you only want to ever have 10 bytes stored? Or are you saving a stream? When you want to read it back would you be showing all the data stored thus far? What's the expected data rate? If it's a slow dribble of data to the card that would warrant a different approach than if you're going for realish-time.

If you can describe your program requirements I'll see wht I can do to help you out.

There's no obvious reason why uFat should interfere with your RTC. It sounds like you're using 2wire for the clock. I have a board that uses I2C components simultaneously with hardware SPI without a problem, I may need to look over your code.

Charlie