Compiling an SD/MMC and fat16 library

hey gang,

first i looked at arduino.cc for a mmc or sd card solution, but i didn´t found something attractive for my gps logger project.
So first i tried to get a sd card solution from Ulrich Radig http://www.ulrichradig.de/home/index.php/avr/mmc-sd to work, but that was too difficult for a greenhorn like me to adapt to arduino.
After i read this thread the 10th time i gave it also a try.
Why must you "talk" so crypted? :wink: Only a fog of usable information was around! ggg Only some needed steps were explained... the ".cpp" thing and so on... but you got that to work. Would have been very helpful with a fist full of information more, but who wants a perfect world? :sunglasses:

Okay, what was interesting for me at R.Riegel sd-reader: MMC/SD/SDHC card library , that he says that you can use only the mmc part and simply leave out the fat part. http://www.roland-riegel.de/sd-reader/sd-reader_source_20071213.zip
That´s what i did, because thats enough, i only want the data stream of the gps.nmea on a BIG 1G sd card! So i can safe for sure some points of my movement profile.

For the circuit i took the simple one from Ulrich Radig, level shifting with voltage dividers, each two resistors, works like a charme!


except for the diodes for vcc i used the 3.3V of the diecimilia. there was a reset at the first mount of the board with the sd card in the slot. so i think the FTDI chip got a reset because of a high init current >50mA? At mikrocontroller.net i read a not too small elko should help, that what i´ll add next on the hardware side. May be a 100uF? any suggestions? At the distributor reichelt.de i could read at some newer sd card, that they take a current <40mA. So this could work. Otherwise i´ll take a low drop regulator.

For the arduino i made a new folder in E:\Program Files\arduino-0010\hardware\libraries , called mmc. There i placed the following files:

sd_raw.cpp  sd_raw.h  sd_raw_config.h

They got easily compiled like extensively described above here.

For the first test i used the following code:

#include <sd_raw.h>
#include <sd_raw_config.h>

int incomingByte = 0;      // for incoming serial data

void setup() {
  Serial.begin(9600);      // opens serial port, sets data rate to 9600 bps
  //Initialisierung der MMC/SD-Karte
  Serial.print("System Ready!\r\n");      
  /* setup sd card slot */

  if( !sd_raw_init()   )
  {
    Serial.println("** Keine MMC/SD Karte gefunden!! **");      

  }
  else
  {
    Serial.println("Karte gefunden!!");
  }
  struct sd_raw_info disk_info;



  Serial.print("manuf:  0x"); 
  Serial.print( disk_info.manufacturer,HEX); 
  Serial.println();
  Serial.print("oem:    "); 
  Serial.print( (char*)disk_info.oem); 
  Serial.println();
  Serial.print("prod:   "); 
  Serial.print((char*) disk_info.product); 

  Serial.print("rev:    "); 
  Serial.println(disk_info.revision); 

  Serial.print("serial: 0x"); 
  Serial.print(disk_info.serial,HEX); 
  Serial.println();
  Serial.print("date:   "); 
  Serial.print(disk_info.manufacturing_month); 
  Serial.print('/');
  Serial.print(disk_info.manufacturing_year); 
  Serial.println();
  Serial.print("size:   "); 
  Serial.print(disk_info.capacity); 
  Serial.println();
  Serial.print("copy:   "); 
  Serial.print(disk_info.flag_copy,BYTE); 
  Serial.println();
  Serial.print("wr.pr.: "); 
  Serial.print(disk_info.flag_write_protect_temp); 
  Serial.print('/');
  Serial.print(disk_info.flag_write_protect); 
  Serial.println();
  Serial.print("format: "); 
  Serial.print(disk_info.format); 


}

void loop() {

  // not used for now:
}

This works (nearly), HURRAY!

Get the following output:

Binary sketch size: 4944 bytes (of a 14336 byte maximum)

System Ready!

** Keine MMC/SD Karte gefunden!! **
manuf:  0x0
oem:    
prod:   
rev:    
serial: 0x35FF0102
date:   
size:   4027073545
copy:  
wr.pr.:

some characters are not displayable here.
Where it says, no card found ("** Keine MMC/SD Karte gefunden!! **"), i think it would need only a bit more time for the init?
The later card information seems to be no problem.

Okay, enough for today, hopefully the read write test will follow tomorrow! I pasted the dirty code in here, so others can use the information now and not sometimes. I plan also to add future additions if time allows it. There will also follow experiences with my navilock gps modul (30?, RS232 - me fool did not take the ttl one :frowning: so i had to add a max232 .... story will continue...)

cheers!

And a big THANK YOU at all the arduino gang for doing an awesome job!