View previous topic :: View next topic |
Author |
Message |
yah996
Joined: 24 Sep 2006 Posts: 31 Location: Bergkirchen
|
Posted: Tue Oct 31, 2006 2:16 pm Post subject: SD Card, Timeout for driveinit() |
|
|
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 |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Thu Jan 03, 2008 5:37 am Post subject: |
|
|
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 |
|
|
yah996
Joined: 24 Sep 2006 Posts: 31 Location: Bergkirchen
|
Posted: Thu Jan 03, 2008 10:14 pm Post subject: |
|
|
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 |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Fri Jan 04, 2008 12:12 am Post subject: |
|
|
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 |
|
|
tomi
Joined: 22 Feb 2005 Posts: 155 Location: Universe
|
Posted: Sat Jan 05, 2008 12:31 am Post subject: |
|
|
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 _________________ Best regards,
/Tomi |
|
Back to top |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Sat Jan 05, 2008 3:14 am Post subject: |
|
|
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 |
|
|
tomi
Joined: 22 Feb 2005 Posts: 155 Location: Universe
|
Posted: Sat Jan 05, 2008 1:46 pm Post subject: |
|
|
Hi,
yes, this I can confirm, it work nicely 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 |
|
|
epardaz
Joined: 01 Jan 2008 Posts: 2
|
Posted: Sun Jan 06, 2008 8:07 am Post subject: YES I have the same problem |
|
|
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 |
|
|
tomi
Joined: 22 Feb 2005 Posts: 155 Location: Universe
|
Posted: Sun Jan 06, 2008 4:03 pm Post subject: |
|
|
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 |
|
|
AdrianJ
Joined: 16 Jan 2006 Posts: 2483 Location: Queensland
|
Posted: Sun Jan 06, 2008 10:44 pm Post subject: |
|
|
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 |
|
|
yah996
Joined: 24 Sep 2006 Posts: 31 Location: Bergkirchen
|
Posted: Wed Jan 09, 2008 9:13 pm Post subject: |
|
|
Hi Adrian,
it works also for me. Many thanks, great job! |
|
Back to top |
|
|
taroosheh
Joined: 16 Mar 2007 Posts: 32 Location: Iran
|
Posted: Sun Sep 28, 2008 7:46 pm Post subject: hi |
|
|
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 |
|
|
oe9vfj
Joined: 17 Jun 2004 Posts: 269 Location: Austria, Hard
|
|
Back to top |
|
|
|