SD Card Interface with MCF51JM128

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SD Card Interface with MCF51JM128

2,842 Views
Paven
Contributor I
Hi, I am working on a project which requires SD-Card Interface. I use SPI1 of the MCF51JM128 for communicating with the SD Card. I couldnt able to initialize the SD-Card, when I send the CMD0 and waiting for the response 0x01, I am always getting the response as 0xFF instead of 0x01. I changed the baud rates, clock polarites(CPHA,CPOL) all in vain. Then, I tried the SPI communication with another board(SLAVE). I can able to achieve the communication between these boards. I dont know where I am wrong, I followed the same code of "SD_Reader_V2.mcp". The only difference is I am using SPI1 insted of SPI2. I need some help to solve this problem. Kindly waiting for positive reply. Thanks, Pavendhan Yadav
Labels (1)
0 Kudos
10 Replies

708 Views
celsoken
Contributor V

Dear Paven,

 

I don't know if it is the same case but check the link:

http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&message.id=7443#M7443

 

I hope it helps.

Cheers,

 

Celso

0 Kudos

708 Views
Paven
Contributor I

Dear Celso,

 

Thanks for your suggestion.

I had already tried the same but didn't get the correct response.

I also checked the whole forum regarding the SDCard interface and tried out the suggestions in the posts all are in vain.

 

So can you please find me a possible way to get this sorted.

 

Thanks,

Paven

0 Kudos

708 Views
celsoken
Contributor V

Dear Paven,

 

Maybe you could try to run your software on SPI2 at the same hardware, maybe your software is a little bit different. Open your premises, don't assume everyhing is right. If you get stuck on it, it could take weeks to get out.

 

Have you scoped the SPI lines?

If you want help in your code, maybe it would be better to post it. 

 

Cheers,

 

Celso

 

0 Kudos

708 Views
Paven
Contributor I

Dear Celso,

 

Please find the attachment for my code and schematic of my hardware.

I tried the SPI communication with another board and it seems to be working.

 

Please suggest me if any changes to be made on the code or on the hardware.

I can't try the same on SPI2 because I am using those pins for some I/O functions.

 

I tried to scoop the lines while in debug mode by single stepping

I got the correct signals on SS1 pin and couldn't able to see any pulses on the other pins (MOSI,MISO,SPCLK)but can see some kind of level changes (looks like spikes)on it initially.

 

 

Thanks,

Paven

 

code.c

schematic.jpg

Message Edited by t.dowe on 2009-10-05 10:27 AM
0 Kudos

708 Views
celsoken
Contributor V

Paven,

 

I don't know your processor frequency, I'm working on 24 MHz and the SPI baud rates don't match on yours.

In my case I've got SPIBR=0x15 for 400KHz and 0x11 for 3 MHz.

 

Cheers,

 

celso

0 Kudos

708 Views
Paven
Contributor I

Dear Celso,

 

My processor frequency is 16MHz.

 

spi baud rate = bus clock/(prescalar*divisor)   // Refer page 337 on MCF51JM128RM.pdf

                   = 8MHz/(5*4)

                   = 400KHz

 

In your case, your processor freq is 24MHz

  

So, baud rate = 12MHz/(2*64)

                   =  93750Hz

 

I am confused.

Can you just explain your baud rate calculation.

 

Thanks,

Paven

0 Kudos

708 Views
celsoken
Contributor V

Sorry Paven,

 

The frequency I was talking about is the internal frequency.

I've checked and I'm working on 187,5KHz on low speed and 3 MHz on hi-speed.

I can't check in on scope right now, but I'll probably check this week.

 

Cheers,

 

Celso

0 Kudos

708 Views
Paven
Contributor I

Dear Celso,

 

      I have tried to shot the sequences of the SPI data (MOSI) that is sent to the SD Card.

I shot that and added in the attachment for your view.

The first 10 0xFF 's were the delay for 80 clocks with CS = 0.

Then, I send 8 0xFF 's with CS = 1 and that data is not seen the MOSI pin.

Then I send the command, 4 zero's and CRC.

After I tried to read from the SD Card with retry count 25.

But, I am always getting 0xFF  as the response.

 

I hope this may give some clue to you about the issue.

Waiting for your reply.

 

Thanks,

Paven

 

CHECK.JPG

Message Edited by t.dowe on 2009-10-07 08:59 AM
0 Kudos

708 Views
PaoloRenzo
Contributor V
Have you tried pull-ups? Before configuring pins from input (default) to output, have you turned them to high state? Specifically for the chip select pin. If it's low, it will be detected as a SPI transaction. Are the SPI pins only connected to your SD card connector? Or some of them are shared?
0 Kudos

708 Views
Paven
Contributor I

Dear Celso,

Thanks for your kind co-operation.
I am waiting for your quick reply.


Thanks,
Paven
0 Kudos