Page 2 of 2
Re: MMC_SPI problems on STM32
Posted: Tue Dec 20, 2011 5:49 am
by CheBuzz
And I finally figured out what the problem was. As best as I can determine, I was trying to read the card too soon before power was applied. Changing MMC_POLLING_DELAY to 100 and MMC_POLLING_INTERVAL to 10 in halconf.h allowed enough time after power up to get everything working well.
Re: MMC_SPI problems on STM32
Posted: Tue Dec 20, 2011 9:10 am
by Giovanni
Looking at your code: You don't need to do spiObjectInit(), it is a static driver and the object is already initialized, however I doubt this is your problem. Your thread also seems to access the MMC before an insertion event initialized it using mmcConnect(). Apparently you do f_open() before the mmcConnect() executes, the order of operations is not respected.
In general I can only recommend sticking to the STM32F103 FatFS demo code as-is, at least initially, and running with all debug options activated in order to catch possible errors.
Giovanni
Re: MMC_SPI problems on STM32
Posted: Tue Dec 20, 2011 6:05 pm
by CheBuzz
I initially did follow the example almost exactly. Those were things I had added in my initial debugging before hooking up the logic analyzer. The problem was trying to talk to the SD card too soon after power was applied. The SD card simply never responded. The moment I changed the polling interval and the insertion events required before initialization, it came up just fine.
I wonder if this is a common problem for people who power up with the card already inserted or if it is unique to my board/SD card.
Re: MMC_SPI problems on STM32
Posted: Wed Dec 21, 2011 8:52 am
by Giovanni
If you work with a card always inserted then a good approach would be to call mmcConnect() until it is successful (may be with a 100mS delay between calls) without messing with the timers.
Giovanni
Re: MMC_SPI problems on STM32
Posted: Wed Dec 21, 2011 9:53 am
by noether
CheBuzz wrote:I initially did follow the example almost exactly. Those were things I had added in my initial debugging before hooking up the logic analyzer. The problem was trying to talk to the SD card too soon after power was applied. The SD card simply never responded. The moment I changed the polling interval and the insertion events required before initialization, it came up just fine.
I wonder if this is a common problem for people who power up with the card already inserted or if it is unique to my board/SD card.
If your board/application allows to remove/insert SD cards in a hot way, it might to be useful to employ the card present pin, then read the SD card datasheet for knowing its start-up time, and multiply it by two for waiting until call the mmcConnect routine.