Go Down

Topic: SD card read/write with Arduino (Read 112 times) previous topic - next topic

harima2

Hi everybody..

I would like to change the pin select  SS 10 (because 10,11,12,13 is yet busy );

for example define Slave Select 8

..do you know how to make this...?  

smelios

#106
Apr 08, 2009, 05:28 am Last Edit: Apr 08, 2009, 05:33 am by smelios Reason: 1

Quote
Posted by: breenmachine
A few people have noticed that your writes to the card "dissappear" after restarting the Arduino. The block size is set up to be 512 bytes, and in the code on the first page, a 512 byte buffer is kept, once it is full, it is written out to the card.

This can be trivially disabled so that all writes are written to the card immediately (no buffering). Just open up "sd_raw_config.h" and look for the line:
#define SD_RAW_WRITE_BUFFERING 1
change it to
#define SD_RAW_WRITE_BUFFERING 0

and you should be all set...dunno if someone else already posted this but I saw the question asked and couldn't find the answer myself so I decided to take a look at the code.



If this is true you just saved me a lot of trouble  ;D
Can this be done with the read function as well? I think a 512 byte buffer gets filled there too.

smelios

I tried changing

#define SD_RAW_WRITE_BUFFERING 1
to
#define SD_RAW_WRITE_BUFFERING 0

with no luck, does that header file need to be recompiled or can i just change it and save?

shyguyy2k

recompile recompile, restart the arduino IDE

smelios

Sorry im a noob when it comes to this stuff. I opened sd_raw_config.h in microsoft visual c++ 2005 and the option to recomplie isn't available. What should I do?

shyguyy2k

Err... I meant to restart the Arduino executable... that you use to write code and upload to the board with.

Justin

You rock!

I just got this working out of the box.  Nice job and thanks!

Justin
:D

zklapow

im wondering if would be possible to bootload the arduino from the SD card. The arduino recieves its sketch through the tx and rx pins right so theoretically if you had a 2 cores one to read the sketch and transmit it to the arduino and the arduino itself it could be used as a bootloader.

florinc

What would be the benefit of this? The sketch residing on SD card instead of internal flash memory?

bHogan

I could think of one advantage. If you had a commercial product the users could upload "new versions" themselves. Dribbleware!  :D
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

florinc

Right, good point. A user upgrade would consist in copying the hex file on the SD card, easier than asking the user to go through the Arduino IDE.

ReCreate

Ummm...
I tried the example code after installing the library, and i get:
Code: [Select]

from D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:13:

D:\Program Files\arduino-0017\hardware\libraries\SDcard\/sd_raw_config.h:86:6: error: #error "no sd/mmc pin mapping available!"

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp: In function 'uint8_t sd_raw_init()':

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:167: error: 'configure_pin_mosi' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:168: error: 'configure_pin_sck' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:169: error: 'configure_pin_ss' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:170: error: 'configure_pin_miso' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:172: error: 'unselect_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:198: error: 'select_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp: In function 'uint8_t sd_raw_read(uint32_t, uint8_t*, uint16_t)':

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:418: error: 'select_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:423: error: 'unselect_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:455: error: 'unselect_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp: In function 'uint8_t sd_raw_write(uint32_t, const uint8_t*, uint16_t)':

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:663: error: 'select_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:668: error: 'unselect_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:689: error: 'unselect_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp: In function 'uint8_t sd_raw_get_info(sd_raw_info*)':

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:809: error: 'select_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:814: error: 'unselect_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:863: error: 'unselect_card' was not declared in this scope

D:\Program Files\arduino-0017\hardware\libraries\SDcard\sd_raw.cpp:908: error: 'unselect_card' was not declared in this scope


Its a Shame it didn't work...Can someone tell me what i did wrong?
Also, I have a question, What would happen if you disconnect the card and connect it into a card reader?
Would it show up as a TXT file or a file without extension or will you have to use a "disk editor" to manually see the bytes and sectors of the stick?

ReCreate

And i have another question, How do i connect my SD card?
Do i need to buy one of the shields out there?

Montspy

#118
Sep 26, 2009, 08:07 am Last Edit: Sep 26, 2009, 09:54 am by Montspy Reason: 1
Hi ! I'm new in the forum.
First : thanks for this tutorial It looks like very easy to follow.
I just have 2 questions :
I have a handful of 470 and 180 Ohms resistors, is that possible to replace the 1.8kO by a 180O  and the 3.3kO by a 510O. In theory it's OK :
Vout = Vin x R2/(R2+R1)
Vout = 5 x 470/(470 + 180)
Vout = 3.62V

My 2nd question : Is the Arduino has a 3.3V output to connect the 4th pin of the SD card ?

Bye.
Montspy.

Fritz Brause

I have followed the instructions 1:1, compiled the demo sketch, but can never manage to get over "MMC/SD initialization failed". Is there a problem with Arduino Duemilanove ATMega328?

The SD Card is fat16 formatted...

In desparate need for an answer,
fritz

Go Up