View previous topic :: View next topic |
Author |
Message |
OpenSys
Joined: 15 Oct 2010 Posts: 19
|
mmc card error with 18f4620 and enc28j60 |
Posted: Sat Nov 13, 2010 3:10 pm |
|
|
Hello,
I use the ccs example ex_st_webserver2 to test mmc card in fat32, but always return MMC_EC_NOT_IDLE in mmc_init.
I check all hardware connection and seems ok, I also have shared the SPI pins with Ethernet controller.
I use a 128M 2G and 4G mmc cards, I get the same error.
I get IP address and lcd show IP address.
The web page also shows "500 Error"
I use a 10mhz crystal.
Config pins:
Code: |
#define EXT_FLASH_PIN_SCL PIN_C3 //o
#define EXT_FLASH_PIN_SDI PIN_C4 //i
#define EXT_FLASH_PIN_SDA PIN_C5 //o
#define EXT_FLASH_PIN_SELECT PIN_C2
|
Please point me in the right direction.
Vasco Santos |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sat Nov 13, 2010 8:57 pm |
|
|
OpenSys wrote: | MMC_EC_NOT_IDLE in mmc_init |
I don't use that particular library, but that sounds like an SPI clock idle problem.
.... Yes, the ENC28J60 is a mode 0 device, while the SD card is mode 3. Those use opposite clock polarities. You'll probably need to call spi_setup every time you switch between devices to set the bus into the correct mode. _________________ Andrew |
|
|
OpenSys
Joined: 15 Oct 2010 Posts: 19
|
|
Posted: Sun Nov 14, 2010 5:58 am |
|
|
andrewg wrote: | OpenSys wrote: | MMC_EC_NOT_IDLE in mmc_init |
I don't use that particular library, but that sounds like an SPI clock idle problem.
.... Yes, the ENC28J60 is a mode 0 device, while the SD card is mode 3. Those use opposite clock polarities. You'll probably need to call spi_setup every time you switch between devices to set the bus into the correct mode. |
thank you for your answer.
So best way is set other pins in pic do run the spi, the clock, sdi and sdo right?
What driver you use ? |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sun Nov 14, 2010 7:43 am |
|
|
OpenSys wrote: | What driver you use ? |
I use mmcsd.c/fat.c, while you're using mmc_spi.c, right?
OpenSys wrote: | So best way is set other pins in pic do run the spi, the clock, sdi and sdo right? |
I don't understand your question.
Actually, having a look at mmc_spi.c I can see that it is 'bit banging' the SPI bus, while the ethernet driver will be using the hardware SPI peripheral.
I would recommend switching to mmcsd.c which can be configured to use hardware SPI. Then I would try adding setup_spi calls to switch to the correct mode before you use each device. _________________ Andrew |
|
|
OpenSys
Joined: 15 Oct 2010 Posts: 19
|
|
Posted: Sun Nov 21, 2010 7:45 am |
|
|
Thank you,
But this mmc only works if the Ethernet module is off, so I pass the webpages to one eeprom with mpfs but have a problem reading the web page, I post it in:
http://www.ccsinfo.com/forum/viewtopic.php?t=44073
Regards.
VS |
|
|
andrewg
Joined: 17 Aug 2005 Posts: 316 Location: Perth, Western Australia
|
|
Posted: Sun Nov 21, 2010 8:35 am |
|
|
I've not used mpfs, so I can't help you there, but I can say that I have successfully mixed different mode SPI devices - Mode 0 for the Ethernet chip and Mode 1 for a DS1307 RTC. I modified the RTC driver to switch to Mode 1 before any data transfer and switch back to Mode 0 when finished. You will need to do something similar - switch to Mode 3 before any SD accesses and switch back to Mode 0 before allowing the Ethernet library to do its thing. _________________ Andrew |
|
|
OpenSys
Joined: 15 Oct 2010 Posts: 19
|
|
Posted: Sun Nov 21, 2010 12:58 pm |
|
|
andrewg wrote: | I've not used mpfs, so I can't help you there, but I can say that I have successfully mixed different mode SPI devices - Mode 0 for the Ethernet chip and Mode 1 for a DS1307 RTC. I modified the RTC driver to switch to Mode 1 before any data transfer and switch back to Mode 0 when finished. You will need to do something similar - switch to Mode 3 before any SD accesses and switch back to Mode 0 before allowing the Ethernet library to do its thing. |
Thank you for all your help, now I fixed it with eeprom |
|
|
|