SPI Interface with the MMC (Multimedia Card)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

SPI Interface with the MMC (Multimedia Card)

2,803 次查看
Taoufik
Contributor I
Hi,
I want to communicate with a Mutimedia Card using the SPI interface of my processor MC9S12E64.
When i send a CMD0 for setting the MMC to the SPI mode, i get the correct answer (0x01) from the MMC. But when i send the CMD1 to the MMC for startting the initialisation of the MMC, i get also 0x01 us answer, it must be a zero.
Is there any application note by Freescale talking about the MMC?
Has anybody an example code for this aplication?
Think you for your fats reaction.
Bye
T. El Boubkari
 
Message Edited by t.dowe on 2009-10-20 11:45 PM
标签 (1)
0 项奖励
6 回复数

832 次查看
JimDon
Senior Contributor III

Well for one thing it looks like you did not deselect the card between commands.

CS is like a reset to the logic, and indicates the start of a new command. I deselect and send an FF byte after each command.

Although you said MMC, is it really an SD card that you are using?
The slots are the same, but the specs are slightly different.




Message Edited by JimDon on 2007-09-27 04:30 PM
0 项奖励

832 次查看
JimDon
Senior Contributor III
I should thank you for not calling me an idiot, but to be honest it would have been ok if you pointed out my error.
Because now, in the interest of helping others by not leaving an incorrect statement stand, I have to correct myself.


Code:
 0001 4f0020fc     [4]     BRCLR _SPISR,#32,*+0 ;abs = 0001

 
This is branch if clear, not bit clear as I mistook for, so of course it is correct.

I should have taken more time before jumping to a conclusion, and I am sorry if I mislead or confused anyone.

0 项奖励

832 次查看
JimDon
Senior Contributor III
Well upon further investigation, there are other problems with the code.

For example:

Code:
void SPISendChar (unsigned char data){    while (!SPISR_SPTEF);   /* wait until transmit buffer is empty*/    SPIDR = data;    /* Transmit counter*/}
This generates the code:

Code:
  0001 4f0020fc     [4]     BRCLR _SPISR,#32,*+0 ;abs = 0001

 So what you doing is attemping to clear the bit.
The code I use is:
Code:
  while(!(SPI0SR & SPI0SR_SPTEF_MASK) )// Wait for write to end.      ;

Which reads the register, masks the bit, and tests it (and seems to work).




 

0 项奖励

832 次查看
Taoufik
Contributor I
Thank you Jim for your effort.
I solved my problem with littel delays (for lus) between CS low and send command. This was my problem.
Best Regards,
Taoufik


Message Edited by Taoufik on 2007-10-04 10:00 AM
0 项奖励

832 次查看
JimDon
Senior Contributor III
Well thank you for telling me how things turned out.

I was thinking about the fact you are using in interrupt. If you want to get maximum transfer rate, you should not use the interrupt.

If you are clock the SPI at max, it takes 16 cycles to clock the data out. You have to wait that amount of time before the interrupt happens. The over head of the interrupt is at least 16 cycles, so you are at least doubling the time it takes to send/receive a byte.

0 项奖励

832 次查看
Taoufik
Contributor I
Hi Jim,
I've deselcted the Card between the 2 commands, but no change in the data (0x01) coming from the MCC.
I'm using a MMC, not SD Card.
 
 
0 项奖励