c't

c't-Projekte - Mailinglisten


[Voriger (Datum)] [Nächster (Datum)] [Voriger (Thread)] [Nächster (Thread)]
[Nach Datum][Nach Thread]

Re: [ct-bot] SPI-Hardwareumbau

Absender: Timo Sandmann
Datum: Mo, 15.09.2008 20:22:06
In-reply-to: <000001c91741$7daccec0$0400a8c0@mexpnew>
References: <000001c91741$7daccec0$0400a8c0@mexpnew>


Hallo Frank,

Am 15.09.2008 um 16:43 schrieb Frank Menzel:
Hallo Timo,
er gibt jetzt aus: Fehler 3 an der Stelle 37f. bei Map_delete selbst
zeigt er diesen eine Adresse weiter an bei 380.

was ist denn die Anfangsadresse der Map-Datei? Nur interessehalber.

Tja, also Fehler 3, was wohl das Ergebnis von mmc_write_sector ist. Aber
woran liegt's ?

Probiere bitte mal den angehängten Patch aus. Am besten zuerst den MMC- Test und dann das Löschen der Map. Ich habe das jetzt nicht großartig getestet, daher erstmal nur als Patch.

Grüße,
Timo

### Eclipse Workspace Patch 1.0
#P ct-Bot-svn
Index: mcu/mmc.c
===================================================================
--- mcu/mmc.c	(revision 1483)
+++ mcu/mmc.c	(working copy)
@@ -403,30 +403,36 @@
 #ifdef MMC_AGGRESSIVE_OPTIMIZATION
 #if 1
 	uint16_t timeout;
+	uint8_t timeout_high;
 	SPDR = 0xff;
 	asm volatile(
 		"ldi %A0,lo8(-1)	; timeout	\n\t"
-		"ldi %B0,hi8(-1)	; timeout	\n\t"
+		"ldi %B0,hi8(-1)	; =			\n\t"
+		"mov %1,%A0			; 0xffffff	\n\t"
 		"1:								\n\t"
-		"sbiw %0,1			; timeout--	\n\t"
+//		"sbiw %0,1			; timeout--	\n\t"
+		"subi %A0,1			; timeout--	\n\t"
+		"sbci %B0,0						\n\t"
+		"sbc %1,__zero_reg__			\n\t"
 		"breq 2f						\n\t"
-		"adiw %0,1			; 2 nop		\n\t"
-		"sbiw %0,1			; 2 nop		\n\t"
-		"adiw %0,1			; 2 nop		\n\t"
-		"sbiw %0,1			; 2 nop		\n\t"
-		"nop				; 1 nop		\n\t"
+		"adiw r28,1			; 2 nop		\n\t"
+		"sbiw r28,1			; 2 nop		\n\t"
+		"adiw r28,1			; 2 nop		\n\t"
+		"sbiw r28,1			; 2 nop		\n\t"
+//		"nop				; 1 nop		\n\t"
 		"ldi r25,lo8(-1)	; 1 nop		\n\t"
-		"in r24,%1			;			\n\t"
-		"out %1,r25			;			\n\t"
+		"in r24,%2			;			\n\t"
+		"out %2,r25			;			\n\t"
 		"cpi r24,lo8(-1)	; == 0xff?	\n\t"
 		"brne 1b						\n\t"
 		"2:									"
-		: "=&y"	(timeout)
+		: "=&d"	(timeout), "=&r" (timeout_high)
 		: "M" (_SFR_IO_ADDR(SPDR))
 		: "r24", "r25"
 	);
 #else
 	uint16_t timeout = 0xffff;
+	uint8_t timeout_high = 0;
 	/* warten, bis Karte mit "0xff" antwortet */
 	uint8_t response = 0;
 	SPDR = 0xff;
@@ -449,7 +455,7 @@
 #endif	// LED_AVAILABLE
 	os_exitCS();

-	if (timeout == 0) {
+	if (timeout == 0 && timeout_high == 0) {
 		mmc_init_state = 1;
 		return 3;
 	}