CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

mmc card error with 18f4620 and enc28j60

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
OpenSys



Joined: 15 Oct 2010
Posts: 19

View user's profile Send private message

mmc card error with 18f4620 and enc28j60
PostPosted: Sat Nov 13, 2010 3:10 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Sat Nov 13, 2010 8:57 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 14, 2010 5:58 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Sun Nov 14, 2010 7:43 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 21, 2010 7:45 am     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Sun Nov 21, 2010 8:35 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Nov 21, 2010 12:58 pm     Reply with quote

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 Smile
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group