2017-08-10 06:25 PM
I have an ST STM32F405 microprocessor. I generated my IAR Embedded Workbench 7.4 files using STM32 Cube software. I'm trying to use the SD card resources to access a micro SD card on our custom board. When I use the debugger in IAR it can access the SD card and the data files on-board no problem. However, as soon as I disconnect the debugger and run in standalone mode, I can't access the SD card. I have traced it to a failure of function disk_initialize in the diskio.c file. When it runs the command:
stat = disk.drv[pdrv]->disk_initialize(disk.lun[pdrv]);
I get a value of 0 when it succeeds and the debugger is attached. But a value of 1 when running in standalone mode.
I read online that perhaps the SDIOCLK divide factor should be changed from 1 to 4 <= but I did that and it did not help. I'm not sure what else to check.
How can I debug this?
2017-08-11 05:54 AM
Some more information on this. I probed the CLK pin on the SD card with an oscilloscope. When I run with the debugger, it oscillates at 8 MHz. However, when I run in standalone mode, it is oscillating at 400 kHz. This is likely the problem. Any idea why the clock responds differently in the two cases and, more importantly, how I can guarantee a clock rate?