2014-12-18 07:23 AM
Hi guys, I'm trying to use an SD card with the aforementioned chip on the Primer2. I started from a working project but when ported to my application, it simply doesn't work. Anyone can help?
In detail, I've ported the interface's code from the STM3210E-EVAL and just adapted some functions to work with FatFS. #stm3210e-eval #stm32f103 #sdio2014-12-18 08:26 AM
Probably want to enable the NVIC before generating interrupts. Watch for the 32-bit overflow on cards >2GB
2014-12-18 08:40 AM
Currently I'm using a 2GB sdcard formatted as FAT32 with 512bytes blocks. I've just added the NVIC configuration for both SDIO and DMA, still not working.
case
MMC :
SD_Init();
SD_GetCardInfo(&SDCardInfo2);
SD_SelectDeselect((uint32_t) (SDCardInfo2.RCA << 16));
SD_EnableWideBusOperation(SDIO_BusWide_4b);
//SD_SetDeviceMode(SD_DMA_MODE);
NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
NVIC_InitStructure.NVIC_IRQChannel = SD_SDIO_DMA_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
NVIC_Init(&NVIC_InitStructure);
return
0;
There is the
from which I started. Any suggestion will be highly appreciated
2014-12-18 09:11 AM
I don't have a Primer 2
Ok, but why do you initialize the interrupts last, wouldn't you want that working first? I have an STM3210E-EVAL, perhaps you can enumerate the differences between the boards, so I can gauge how complicated a port it would be.2014-12-18 09:15 AM
So what debugging have you actually done? ''Not working'' is a bit nebulous. Does it call the initializations code, have you break pointed it? Do you have any of the non-MMC nodes working, or is that just junk left over? Do any of the SD commands work, what kinds of errors and status issues do you observe?
Suggest you get the SD abstraction working outside of FatFs functionality, prove the Read/Write functionality gets the sectors you expect.2014-12-18 09:42 AM
There aren't a lot of differences between the boards (speaking of SD connection and clock), just the Primer2 hasn't an SD_DETECT line, so I've disabled it in the code (SD_Detect() returns always SD_PRESENT). Right now I've no debugger with me (I'm programming through an stm32vl-discovery integrated SWD), so I've just checked simple operations, for example f_mount seems to work but I can't be 100% sure. Now I'm trying to check if the SD driver is working, excluding the FatFS module. Do you a simple working code for the EVAL board? Maybe I can restart from here.
2014-12-18 10:02 AM
STM3210E-EVAL_FW_V2.1.0\Utilities\STM32_EVAL\STM3210E_EVAL\stm3210e_eval_sdio_sd.c
2014-12-18 11:12 AM
The drivers seems to behave strangely with the function:
static
SD_Error CmdError(
void
)
inside fatfs_sdio_sd.c. Seems at the point that calls:
FlagStatus SDIO_GetFlagStatus(uint32_t SDIO_FLAG)
within stm32f10x_sdio.c.
The code is pretty identical to the one from stm3210e-eval-demo V2.1.0, still no success. However the only example that works 100% comes from a Ride7 project and uses a syntax not welcome from Keil.
Still tryin' to figure it out, butwithout debugger seems hard
2014-12-18 03:55 PM
I've solved the main problem recreating the entire project from the previously linked example, and now the project includes the latest fatfs version. Now I'm facing another problem: ''ff.h'' defines really useful functions like f_puts, f_printf but i can't use them. uVision successfully compiles every file, and the main has the ''#include ''ff.h'', the path to /fatfs/src is also present for the compiler. I have this linker error:
.\obj\project.axf: Error: L6218E: Undefined symbol f_printf (referred from main.o).However if anyone interested there is the current working