Guys, Try to study the sources of this project http://www.dharmanitech.com/2011/05/microsd-atmega32-datalogger.html, specially, sd_routines.h and SD_routines.c, is not much code, and it address also SDHC.
On Wednesday, September 19, 2012 8:34:39 AM UTC+3, Sebastien Lelong wrote: > > Hi guys, > > > Trev, from Jaluino, has made several tests with SD cards, running on > Jaluino Bee. He's been able to make 2GB SD Card working, see below. Matt, > can you tell us more about this SD_DELAY_AFTER_WRITE constant ? When true, > it just waits, when false, it does a lot more than just wait ? > > Pull-ups configured with this test: /SS and SCK > Sample: > https://code.google.com/p/jaluino/source/browse/trunk/samples/jaluino_bee_sd_card.jal > with modified SD_DELAY_AFTER_WRITE to false (in lib jaluino.jal) > > > Cheers, > Seb > > > ---------- Forwarded message ---------- > > You might recall issues I had with some uSD cards not working with the Bee > and your test SD write/read program. > > Well, having purchased a single 2Gb uSD card off eBay and finding it > worked and was branded ADATA I asked the Chinese vendor if I bought more, > would they also be ADATA branded. He said yes, so I bought six more. > However, when they arrived they were generic, unbranded cards. Three of > them worked and three of them didn't work with the Bee. > > Dang! So tonight while I was re-testing the three non-working cards, I > removed a card after the Bee had "written" but after it got stuck and did > not do any "reading", and then put it back almost immediately. The Bee then > started reading the crad and flashing the LED. Hmmm. So I decided to play > around with the code. > > The first thing I did was add a delay after the stop_write() and before > the start_read(). This made no difference. The next thing I did was add a > second stop_write() immediately after the first one... this worked! > > So now I turned my attention to the sd_card.jal file. > > if SD_DELAY_AFTER_WRITE == TRUE then > _usec_delay (50_000) > else > for 50000 loop > sd_chip_select = low -- enable the sd card > > var byte reply > send_command(SD_STOP_**TRANSMISSION,0,reply) -- stop current > transmission > sd_ready() -- wait till sd card is > ready > send_command(SD_GO_IDLE_STATE,**0,reply) -- command 0, Resets > card to idle state > sd_ready() -- wait till sd card is > ready > > sd_chip_select = high -- disable the sd card > > if !(reply == 0) then > exit loop > end if > end loop > end if > > I first commented out the "if...else" and "end if" and ... it worked! > Looking at the code, I'm not sure I understand how simply delaying for > 50,000us is supposed to be a delay compared with all those commands in the > else clause trapped in a 50,000 loop! > > But be that as it may, the ultimate fix was to track down the > SD_DELAY_AFTER_WRITE constant in the jaluino_bee.jal file and make it FALSE > although I still suspect there's something not quite right about that > sd_card.jal code which I don't understand because it seems to me that the > else clause causes an even bigger delay! > > Anyway, it now works for all the 2Gb uSD cards that I have (although I > can't find the 2Gb Kingston branded one which first caused the problem more > than a year ago). > > Cheers, > TREV. > > -- You received this message because you are subscribed to the Google Groups "jallib" group. To view this discussion on the web visit https://groups.google.com/d/msg/jallib/-/RRug1d2HCbcJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
