Hi, I followed the process of finit using stm32f4 discovery board (connected to microsd) and Kiel rtx, and received an error on finit but was able to format the microsd using the ARM in the next line. Anybody had such experience?
The only thing I did was change the pin assignment of cd (chip detect) from gpioh15 to gpioe15 because the chip did not have gpioh15.
Thx
Have you tried do a sector read from the card? Have you wired it up correctly? Is the GPIOE clock enabled?
Could you cite the directions you followed?
I used addon boards purchased from RS to ensure no hardware problems and connected everything which SDIO_STM32F4xx.c referenced i.e. D0 to PC.08 D1 to PC.09 D2 to PC.10 D3 to PC.11 CLK to PC.12 CMD to PD.02
But instead of using GPIOH15, I used GPIOE15 (as there is no GPIOH15 on the stmf4 board) So I did a search of GPIOH and replaced with GPIOE i.e.:-
/* Enable GPIOH (card detect), GPIOD (command), GPIOC (data) clock */ RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN | ////////////////////GPIOH originally ------------------------------------- /* Configure PH.15 Card Detect input */ GPIOE->MODER &= ~0xC0000000; /////////////GPIOH originally GPIOE->PUPDR &= ~0xC0000000; /* Pin in Input mode */ //////////GPIOH originally ------------------------------------- /* Reset PH.13 */ GPIOE->MODER &= ~(3 << 26); /////////////////////GPIOH originally ------------------------------------- if (!(GPIOE->IDR & (1 << 15))) { ////////////////////GPIOH originally
Where can I find more information on this bit manipulation technique. &= ~ looks like a bit selection of twos complement (correct me if I'm wrong) Thx
There was no compile error, just that could not succesfully initialize when I do fnit, the error flag turns on as below
while (finit(NULL)!= 0) { /* Wait until the Card is ready*/ if (!(count--)) { error_finit=1; break; }
The good thing is that I was able to successfully format after that line as below fformat("M:SD_CARD / FAT32"); //format drive
Which tells me the chip detect pin which I changed to port E does not work, so I'm trying to debug that.
You haven't said what filesystem you're using.
while( finit(NULL) != 0 ) { /* Wait until the Card is ready */ if( !(count--) ) { error_finit=1; break; } }
Doesn't finit() return a value to indicate the nature of the error?
Or, is there some kind of global error variable, or a function to get the "last error"?
If you have the source for the filesystem, have you stepped into finit() to see exactly where it's failing, and how?
What does the assignment mean:-
GPIOE->MODER &= ~0xC0000000; GPIOE->PUPDR &= ~0xC0000000;
Does it equate to: two's complement of 0b11 ? Does it mean the first 2 pins are set to 1 i.e. pin15? Does the ~ supposed to indicate negative number or that the 1st digit is not negative?
Anyway, I decided the best way is to directly solder an SDCARD onto the board with the required pull up resistor values (47k).
The problem is I noticed there are 9 pins on the sdcard not 10 (as per your supplied schematic).
Internet references indicate the Dat3 & CD is the same pin?
CD in this context is a mechanical switch in the socket which is physically actuated by the insertion of a card, per the 10 pins on the socket, one side is grounded, the other pulled to VCC.
You should be able to test this switch function by observing a suitably programmed/configured GPIO pin.
I have rewired the microsd card 100% to your suggested circuit and the same problem occurs i.e. finit fails but the formatting to fat32 works like a charm. Cannot write to the card either.
I am using a 4GB SDHC card, do I need special configuration to use that?
Stack is set to 0x400; heap size is 0x800 My crystal is 8MHz, Keil RTX is set to 60MHz,file system is 168 MHz (same as system clock)