Hallo, ich versuche grade einen SD Karte am SDIO Interface zum laufen zu bringen. Ich benutze das STM32F4Discovery Board. Als erstes versuche ich ein CMD0 zu senden aber wenn ich auf eine Antwort warte kommt immer nur ein Timeout. Eig müsste ich doch 0x01 empfangen, um zu wissen, dass die Karte jetzt im Idle Modus ist. Oder? Hat jemand eine Idee dazu? Die Bsp. von ST zur StdLib bringen mich auch nicht weiter. Moritz
Hallo, ich hab die Pull Ups im Mikrocontroller aktiviert. Reicht das? Hier noch der Code, hab ich vergessen:
1 | #include "stm32f4xx_StdFramework.h" |
2 | |
3 | void SD_Init(void); |
4 | |
5 | uint8_t resp; |
6 | |
7 | int main(void) |
8 | {
|
9 | resp = 255; |
10 | SD_Init(); |
11 | while(1) |
12 | {
|
13 | }
|
14 | }
|
15 | |
16 | void SD_Init(void) |
17 | {
|
18 | /* Clocks */
|
19 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_SDIO, ENABLE); |
20 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); |
21 | RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); |
22 | |
23 | /* GPIO */
|
24 | GPIO_InitTypeDef GPIO_InitStruct; |
25 | |
26 | //PC8..11 SDIO_DATA0..3
|
27 | GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF; |
28 | GPIO_InitStruct.GPIO_OType = GPIO_OType_PP; |
29 | GPIO_InitStruct.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11; |
30 | GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_UP; |
31 | GPIO_InitStruct.GPIO_Speed = GPIO_Speed_25MHz; |
32 | GPIO_Init(GPIOC, &GPIO_InitStruct); |
33 | |
34 | //PD2 SDIO_CMD
|
35 | GPIO_InitStruct.GPIO_Pin = GPIO_Pin_2; |
36 | GPIO_Init(GPIOD, &GPIO_InitStruct); |
37 | |
38 | //PC12 SDIO_CK
|
39 | GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12; |
40 | GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL; |
41 | GPIO_Init(GPIOC, &GPIO_InitStruct); |
42 | |
43 | //Alternate Function
|
44 | GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_SDIO); |
45 | GPIO_PinAFConfig(GPIOC, GPIO_PinSource9, GPIO_AF_SDIO); |
46 | GPIO_PinAFConfig(GPIOC, GPIO_PinSource10, GPIO_AF_SDIO); |
47 | GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_SDIO); |
48 | |
49 | GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_SDIO); |
50 | |
51 | GPIO_PinAFConfig(GPIOD, GPIO_PinSource2, GPIO_AF_SDIO); |
52 | |
53 | /* SDIO */
|
54 | SDIO_InitTypeDef SDIO_InitStruct; |
55 | |
56 | SDIO_InitStruct.SDIO_BusWide = SDIO_BusWide_4b; |
57 | SDIO_InitStruct.SDIO_ClockBypass = SDIO_ClockBypass_Disable; |
58 | SDIO_InitStruct.SDIO_ClockDiv = 118; |
59 | SDIO_InitStruct.SDIO_ClockEdge = SDIO_ClockEdge_Rising; |
60 | SDIO_InitStruct.SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable; |
61 | SDIO_InitStruct.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable; |
62 | SDIO_Init(&SDIO_InitStruct); |
63 | |
64 | SDIO_SetPowerState(SDIO_PowerState_ON); |
65 | |
66 | SDIO_ClockCmd(ENABLE); |
67 | |
68 | //Wait
|
69 | uint32_t i; |
70 | for(i = 0; i < 168000000; i++); |
71 | |
72 | /* SD */
|
73 | SDIO_CmdInitTypeDef SDIO_CmdInitStruct; |
74 | |
75 | //CMD0 - Idle
|
76 | SDIO_CmdInitStruct.SDIO_Argument = 0x00; |
77 | SDIO_CmdInitStruct.SDIO_CPSM = SDIO_CPSM_Enable; |
78 | SDIO_CmdInitStruct.SDIO_CmdIndex = 0x00; |
79 | SDIO_CmdInitStruct.SDIO_Response = SDIO_Response_Short; |
80 | SDIO_CmdInitStruct.SDIO_Wait = SDIO_Wait_No; |
81 | SDIO_SendCommand(&SDIO_CmdInitStruct); |
82 | |
83 | while((SDIO_GetFlagStatus(SDIO_FLAG_CMDREND) == RESET) && |
84 | (SDIO_GetFlagStatus(SDIO_FLAG_CCRCFAIL) == RESET) && |
85 | (SDIO_GetFlagStatus(SDIO_FLAG_CTIMEOUT) == RESET)); |
86 | |
87 | if(SDIO_GetFlagStatus(SDIO_FLAG_CCRCFAIL) == SET) |
88 | {
|
89 | SDIO_ClearFlag(SDIO_FLAG_CCRCFAIL); |
90 | while(1); |
91 | }
|
92 | else if(SDIO_GetFlagStatus(SDIO_FLAG_CTIMEOUT) == SET) |
93 | {
|
94 | SDIO_ClearFlag(SDIO_FLAG_CTIMEOUT); |
95 | while(1); |
96 | }
|
97 | else
|
98 | {
|
99 | resp = (uint8_t)SDIO_GetResponse(SDIO_RESP1); |
100 | SDIO_ClearFlag(SDIO_FLAG_CMDSENT); |
101 | }
|
102 | }
|
Also das Signal ist schon mal richtig: 01 dann 54 mal 0 und dann 10010101. Aber die SD Karte antwortet gar nicht, obwohl alle Kontakte richtig verbunden sind (Provisorisch mit eine doppelreihigen Stiftleiste, Steckbrett und Papier zum festklemmen). Die SD Karte funktioniert auch einwandfrei, da sie von meinem PC richtig erkannt wird. Es handelt sich um eine OCZ 2GB Karte. Moritz
Hallo, richtig weitergekommen bin ich immer noch nicht. Die Signale liegen alle eindeutig an den Pins der SD Karte an, nur antwortet die Karte gar nicht. Wenn ich danach einfach ein CMD55 sende, dann gibt es ein Response von 288. Weiß jemand was das bedeutet? Eig. hab ich gelesen, dass es auf CMD55 eine Antwort vom Type R1 geben soll, welches 1Byte lang ist. Allgemein versuche ich grade heraus zu finden wie man von dem Short Response von ST auf ein R1 oder sonstwas kommt. Das passt mit den Bits vorne und hinten nicht. Hat jemand dazu eine Idee? Moritz
Hallo, also 288 hab ich jezt endlich heraus gefunden ist richtig. Damit sagt die Karte, dass sie jetzt auf ein ACMD wartet. Wenn ich dann ACMD41 sende bekomme ich als Antwort 16744448 was definitiv falsch ist. Wisst ihr welche Antwort ich auf ein ACMD41 erwarten muss? Manchmal kommt es auch zu CRC oder Timout Exceptions. Moritz
Hallo, schau dir mal die PDF-Datei an! http://www.uni-koblenz.de/~physik/informatik/ECC/sd.pdf Da findest du bestimmt was. Gruß G.G.
Danke. Aber das kenne ich schon. Ich finde da irgendwie keinen Zusammenhang zwischen den Responses von ST (32bit) und dem R1, R1b usw. Im Reference Manual hab ich eine jezt Liste gefunden, was die Status Codes bedeutet, aber dass ist was ganz anderes als die normalen Responses, die man überall findet. Moritz
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.