Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

AVR-DOS SDHC cards unreliable?

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> AVR-DOS
View previous topic :: View next topic  
Author Message
Jerry

Bascom Member



Joined: 25 May 2004
Posts: 40
Location: New York

usa.gif
PostPosted: Thu Oct 03, 2013 7:02 pm    Post subject: AVR-DOS SDHC cards unreliable? Reply with quote

Testing with Bascom-AVR Version 2.0.7.6. I have read all posts listed in AVR-DOS forum section and still fumbling around to resolve my problem.
Hi all,
I have been using Niclas Fat-Free SD library and Atmega2561 with 14.745 MHz clock for a while with no problems regardless of card type, card size or card speed, 2GB SD up to 16GB SDXC.
I thought I might like to try AVR-DOS since many additional features are available. My hardware remains the same so I know the interface is good. However, Driveinit() seems very inconsistent sometimes gives no error sometimes error. If I get error and perform Drivereset() and then Driveinit() card will then function without issue, sometimes just doing driveinit() a couple times will work. For some reason it seems very picky regarding the card I use. I have 4 Kingston 4GB SDHC class 4 cards and none of them will initialize with AVR-DOS, however they work fine with FAT-Free. I also have 2 8GB Adata SDHC cards and they almost always work with AVR-DOS. Almost is not really good enough.

What I have done in the past when using FAT-Free, since SD cards vary from different manufacturers is to start initialize hardware SPI at highest speed setting then reduce speed setting using SPSR and SPCR registers along with SPIINIT until initialize is good, then I leave it while using the card for reading and writing data. I have tried doing similar with AVR-DOS and regardless of SPI settings Driveinit() gives mixed and inconsistent results.

Another thing I noticed is when using Disksize() it takes about 1 to 2 seconds to return a value. What could be the reason for that?

I would really like to make use of AVR-DOS and would purchase commercial license if I could get reliable and consistent results from it.
Any comments or ideas on the possible problem would be greatly appreciated.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5915
Location: Holland

blank.gif
PostPosted: Thu Oct 03, 2013 8:04 pm    Post subject: Reply with quote

i yet need to find the first card that does not work. when using AVR-DOS it is important to know that AVR-DOS is the disk operating system library. It works perfect.
But it works together with driver libraries. you can have a driver for XRAM so you can simulate all the AVR-DOS commands, or you can have a driver for a hard disk , CE drive or memory card.
There are different memory card drivers. When using SDHC cards you need to use the proper driver MMCSD_HC.LIB
The lib is written by Josef, the author of AVR-DOS. I altered the lib so it works with MMC cards too. And it was updated for Xmega. One of the updates in 2076 was to get the driver working for some arduino shields. Some shields use the CS pin to control a buffer enable line which is not a good idea since the card is clocked without CS made low. So in 2077 i made that an option. I advise to get the lib from 2077 and test it.
It is also very important that SPI and pins are properly enabled in the bas file that sets up the driver. I think you can always use the highest possible SPI speed for most modern cards.

_________________
Mark
Back to top
View user's profile Visit poster's website
Jerry

Bascom Member



Joined: 25 May 2004
Posts: 40
Location: New York

usa.gif
PostPosted: Thu Oct 03, 2013 9:00 pm    Post subject: Reply with quote

Hi Mark, thank you for the quick reply.
I verified correct port pins defined in Config_MMCSD_HC.bas it is using $lib "MMCSD_HC.LIB"
I'll download the latest and give it a go.
Kind Regards,
Jerry
Back to top
View user's profile
Jerry

Bascom Member



Joined: 25 May 2004
Posts: 40
Location: New York

usa.gif
PostPosted: Fri Oct 04, 2013 2:18 pm    Post subject: Reply with quote

OK found the problem. It was in fact hardware.
Thanks for the help.
Jerry
Back to top
View user's profile
nisse

Bascom Member



Joined: 14 Dec 2006
Posts: 50

sweden.gif
PostPosted: Thu Feb 27, 2014 7:31 pm    Post subject: Reply with quote

Jerry, I have a similar issue, could you share what HW problem you found?
Back to top
View user's profile
Jerry

Bascom Member



Joined: 25 May 2004
Posts: 40
Location: New York

usa.gif
PostPosted: Thu Feb 27, 2014 8:53 pm    Post subject: Reply with quote

nisse wrote:
Jerry, I have a similar issue, could you share what HW problem you found?


Hi nisse,
I am using FET (NXP BSN20) as a level translator to go from 5V processor to 3.3V SD card SPI bus. The pull-up resistor on output of translator clock signal was too weak to allow good rising edge clock and was causing problems. I revised pull-up value from 4.7K ohms to 1K ohms and all was well.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> AVR-DOS All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum