Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

SD Card, Timeout for driveinit()

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

Bascom Member



Joined: 24 Sep 2006
Posts: 31
Location: Bergkirchen

germany.gif
PostPosted: Tue Oct 31, 2006 2:16 pm    Post subject: SD Card, Timeout for driveinit() Reply with quote

Hello,

i have one short question.

Does someone know how to set the timeout, if i do a driveinit() and there is no sd card is inserted? Also is there a return code if no sd card is inserted?

To me it looks like the timeout is about 2 min. or so...

Thanks
K.
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Thu Jan 03, 2008 5:37 am    Post subject: Reply with quote

Yes, I have seen this too. Posted the same query before I saw yours.
_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
yah996

Bascom Member



Joined: 24 Sep 2006
Posts: 31
Location: Bergkirchen

germany.gif
PostPosted: Thu Jan 03, 2008 10:14 pm    Post subject: Reply with quote

I found a short workaround, i changed some hardcoded timeout loops in then "mmc.lib". Like this:
ldi r17, 100 ; try 100 times to get proper response

In my configuration it works now within 10sec for the timeout.
I am still missing a dynamic timeout handler. Also a the insert-switch support in the mmc.lib would be perfect.
Back to top
View user's profile
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Fri Jan 04, 2008 12:12 am    Post subject: Reply with quote

The problem only seems to happen when the MISO ( card data output ) line floats high, hence the random nature.

I had a look in the MMC.LIB code, and modified it too:
_mmc_getresponse:
; Wait for non &HFF response
; Not getting Byte: T-Flag set
push r17
push r18
;ldi r17, 64 ; ask 64 times for response
; clr r17 'removed 4/1/08 AMJ, is set to 100 in calling routine
clr r18
clt ; clear low level error flag
_mmc_getresponse1:
rcall _Byte2SPI_255
cpi r16, &HFF
brne _MMC_GetResponse2
subi r17, 1
; sbci r18, 0 'removed 4/1/08 AMJ
brne _MMC_GetResponse1
set
_mmc_getresponse2:
pop r18
pop r17
tst r16 ; set Z-Flag if Response = 0, do not affect C-Flag
ret

That seems to work. I sent an email to Josef Vogel about this as well.
I dont really see much need for a user alterable timeout, either the card works, or not. As long as the response time is predictable, this is enough.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
tomi

Administrator



Joined: 22 Feb 2005
Posts: 155
Location: Universe

blank.gif
PostPosted: Sat Jan 05, 2008 12:31 am    Post subject: Reply with quote

Hi,

I tested your mod to MMC.lib but in my case it not work well, with inserted card I get error at init 229 and without card error 225. Seem its not work/work depend on card/configuration.
Take this just a note Wink

_________________
Best regards,
/Tomi
Back to top
View user's profile Visit poster's website
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Sat Jan 05, 2008 3:14 am    Post subject: Reply with quote

Yes, I too found it only worked to detect the high level on the line. Some cards need longer time to respond, so I changed it a bit more:

_mmc_getresponse:
; Wait for non &HFF response
; Not getting Byte: T-Flag set
push r17
push r18
;ldi r17, 64 ; ask 64 times for response
; clr r17 'removed 4/1/08 AMJ, is set to 100 in calling routine
ldi r18,5 'set 5 * 256 tries, about 2 sec
clt ; clear low level error flag
_mmc_getresponse1:
rcall _Byte2SPI_255
cpi r16, &HFF
brne _MMC_GetResponse2
subi r17, 1
sbci r18, 0 ;added back in
brne _MMC_GetResponse1
set
_mmc_getresponse2:
pop r18
pop r17
tst r16 ; set Z-Flag if Response = 0, do not affect C-Flag
ret

That seems to work, and gives a max delay of around 2 sec if no card is inserted.

_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
tomi

Administrator



Joined: 22 Feb 2005
Posts: 155
Location: Universe

blank.gif
PostPosted: Sat Jan 05, 2008 1:46 pm    Post subject: Reply with quote

Hi,

yes, this I can confirm, it work nicely Smile Without card, timeout in my case is ~0.5-0.8sec and with card, it work without ny problem. I tested this on real SD card and also in Proteus Sim.

_________________
Best regards,
/Tomi
Back to top
View user's profile Visit poster's website
epardaz

Bascom Member



Joined: 01 Jan 2008
Posts: 2

hong_kong.gif
PostPosted: Sun Jan 06, 2008 8:07 am    Post subject: YES I have the same problem Reply with quote

I test it
josef can solve this problem, by the way it should gets back an error code
but it doesn't
in some cases we need the error codes
Back to top
View user's profile
tomi

Administrator



Joined: 22 Feb 2005
Posts: 155
Location: Universe

blank.gif
PostPosted: Sun Jan 06, 2008 4:03 pm    Post subject: Reply with quote

not know what you mean with no error message, but last mod return error 225 when card is not present, and with card it return standard message.
_________________
Best regards,
/Tomi
Back to top
View user's profile Visit poster's website
AdrianJ

Bascom Expert



Joined: 16 Jan 2006
Posts: 2483
Location: Queensland

australia.gif
PostPosted: Sun Jan 06, 2008 10:44 pm    Post subject: Reply with quote

Thanks for the feedback tomi. The timeout will of course depend on the clock frequency.
_________________
Adrian Jansen
Computer language is a framework for creativity
Back to top
View user's profile Visit poster's website
yah996

Bascom Member



Joined: 24 Sep 2006
Posts: 31
Location: Bergkirchen

germany.gif
PostPosted: Wed Jan 09, 2008 9:13 pm    Post subject: Reply with quote

Hi Adrian,

it works also for me. Many thanks, great job!
Back to top
View user's profile
taroosheh

Bascom Member



Joined: 16 Mar 2007
Posts: 32
Location: Iran

iran.gif
PostPosted: Sun Sep 28, 2008 7:46 pm    Post subject: hi Reply with quote

I have using timer1 in this state and very well responsed

in this case before initializing memry start timer1 and after over flow break this progress and system send a message about memry card not response or not insert into soket

but in general cases time out happend when the power supply not correct voltage or memory card is damaged or befor reset the memory is wakeup but not recive any comands

try this path:
http://electrorc.blogfa.com
Back to top
View user's profile Yahoo Messenger
oe9vfj

Moderator



Joined: 17 Jun 2004
Posts: 269
Location: Austria, Hard

austria.gif
PostPosted: Wed Feb 11, 2009 3:32 pm    Post subject: Reply with quote

The new driver (test-release) for download at http://www.mcselec.com/index2.php?option=com_forum&Itemid=59&page=viewtopic&t=7030 have now a defined timeout of appr. 1 second for all situations.
_________________
regards Josef

DOS - File System for BASCOM-AVR on http://members.aon.at/voegel
Back to top
View user's profile Visit poster's website
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