Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

MMC/SD power up TIME ?

Status
Not open for further replies.

irilias

New Member
hi, i'm new to PIC microcontrollers and will be using one (pic16f877a) to develop a project using an MMC/SD card.

i'm using an 8Mhz crystal, and i used the parameter SPI_CLK_DIV_4 for the setup_spi(), which means a 2Mhz SPi clock rate, and Tcy=1/2000000 sec (at least that's what i got from the datasheet) .anyway, for the MMC to power up it needs at least 1 msec for the supply ramp up time plus the power up time to get to VDD min (2.2 volts), my question is, how much clocks do i need to send to the MMC for it to completley power up?

my colleague told me that 80 clocks should be enough, but i don't think that would do the job, i mean :

80 x (1/2000000) is only 40 microsec ? , i probably need more than that, did i calculate the spi clock rate and Tcy correctly?

here's the code that i wrote (not all of it though, my problem is with the number of clocks to send (the FOR loop) ):

Code:
 int mmc_init() 
{ 
int i; 
SETUP_SPI(SPI_MASTER | SPI_H_TO_L | SPI_CLK_DIV_4 | SPI_SS_DISABLED); 
*0x94 |= 0x40;		// set CKE = 1 - clock idle low 
*0x14 &= 0xEF; 		// set CKP = 0 - data valid on rising edge 
OUTPUT_HIGH(PIN_C2); 	// set SS = 1 (off) 

for(i=0;i<10;i++)  	// initialise the MMC card into SPI mode by sending clks on 
{ 
SPI_WRITE(0xFF); 
} 

OUTPUT_LOW(PIN_C2);  // set SS = 0 (on) tells card to go to spi mode when it receives reset 
SPI_WRITE(0x40);	 // send reset command 
SPI_WRITE(0x00);	 // all the arguments are 0x00 for the reset command 
SPI_WRITE(0x00); 
SPI_WRITE(0x00); 
SPI_WRITE(0x00); 
SPI_WRITE(0x95);	 // precalculated checksum as we are still in MMC mode 
puts("Sent go to SPI\n\r");

any anwsers would be much appreciated, thank you.
 
thank you very much for your reply, well the thing is that i'm not sure if i'm doing the right calculations :confused:, i mean does the SPI_CLK_DIV_4 mean dividing 8Mhz (the crystal frequency) by 4 to get 2 Mhz the SPI clock rate, and a Tcycle of 1/2000000 sec ?

and does one Tcycle represent one clock?

i just need to clarify this thing so i can code it correctly.
Thanks again,
 
A pic16 with an 8mhz Xtal will be running at 2mhz... There is an internal divider BEFORE anything else... TOSC = FOSC/4..

So you need concern yourself with a clock cycle of 0.5μS... SPI, however, is good for 2mhz operation ( device dependant of course )...

I think your friend is telling you that the MMC/SD card NEEDS 80 clocks to initialize.. I have read this somewhere, I don't think its a power up time, Its a "clear out the old data" type of initialization...


I know when you try to initialize the card there will be quite a few re-tries before its up and running..

If you look at the documentation for the MMC/SD operation you can see for yourself.
 
ok, so the pic is running at 2Mhz, which means the SPI is functionning on 500Khz clock rate (SPI_CLK_DIV_4) . and that would give us Tcycle=1/500000 sec (equivalent of one clock), right?

if i'm on the right path, 80 clocks would still not give us the right amount of time needed for the MMC?
80 x (1/500000) = 160 microsec ?!

I'm sorry for being such a noob but i just realy want to know whether or not my reasoning is right, Thank you
 
Status
Not open for further replies.

Latest threads

Back
Top