Pages: [1]   Go Down
Author Topic: SD library bug???  (Read 1196 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi guys!
My device has SD-card datalogger, but there is periodically data lost while this one works:

Datalogger uses SD.h. 2GB SD is connected via SPI.
How can I write data without FAT (using SD as memory block)? 
Or maybe is there the "fast FAT" version of SD.h?
Now speed of data write is about 25Hz, but I need 100Hz+. smiley-sad
Please help to decide this problem.
Logged

0
Offline Offline
Edison Member
*
Karma: 67
Posts: 1673
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

SD cards must be written in 512 byte blocks and random long write latencies are a prosperity of all SD cards.  The SD spec allows occasional write delays of up to 250 milliseconds on a write but typical cards have occasional delays of more like 40-80 ms.  A major reason for these delays is wear leveling of flash memory. Another reason is that flash erase groups are very large in SD cards which can cause the card to be busy.

To write fast, you need a large buffer and multiple threads or you can capture the data in an ISR and buffer it.

I have posted programs using both of these methods at http://code.google.com/p/beta-lib/downloads/list.

AnalogIsrLogger20121219.zip uses an ISR to capture data.

ChibiOSBeta20121217.zip is a more general approach and uses ChibiOS/RT to run separate threads for data capture and writing to the SD.  There are two data logger examples, one for Uno and one for Mega.

fastLoggerBeta20110802.zip has some additional examples of these methods but is somewhat out of date.
« Last Edit: December 19, 2012, 12:41:43 pm by fat16lib » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What about technique of memory-mapping?
Can I write (or read) data to (virtual base pointer + offset) to except SDfat approach at all?   Just memory operations without files etc.
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What about technique of memory-mapping?
Can I write (or read) data to (virtual base pointer + offset) to except SDfat approach at all?   Just memory operations without files etc.

Well but if you keep data in ram you lose it at each reset... What do you mean ?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, I'm talking about approach of using SD via linear memory space.
For example, ((*byte)EEPROM_Base+Offset).  Similar approach is used to access external RAM, after enabling this one in MCU regs.
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, memory mapped files on SD are not possible in this architecture.

-br
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, I don't need files, FAT, etc!  smiley
I just wanna use SD card like a piece of memory, or memory space.
Is it unreal too?
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Even eeprom address space is not mapped in ram address space.

Plus, SD card is accessed through SPI.

Plus, how would you access all of an SD card space (e.g. 4GB) with the limited MCU addresses ?

I think you could, however, write a class with an operator[] that would take care of accessing the SD card somehow (perhaps reading and writing bytes in a big file). That would be quite close to what you want, I think.

I don't see /why/ you're trying to do this. IMHO too much abstraction is /bad/ in a resource constrained environment like an MCU.
Logged

Pages: [1]   Go Up
Jump to: