micro SD / SPI speed

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

micro SD / SPI speed

3,057 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bobi-one on Tue Apr 05 09:06:47 MST 2011
Have somebody  been able to interface sd cadrs via lpcxpresso with spi clk speed grerater than 12Mhz. As far as i know the micro sd card I'am using can achieve much greater speeds. And i think with:
LPC_SYSCON->SYSTICKCLKDIV  = 0x02;
LPC_SSP->CR0 = 0x00C7; 
LPC_SSP->CPSR = 0x2;

it should been able to run at 24Mhz but is not. I'll be greatfull for all the help and hints i can get. : )
0 Kudos
12 Replies

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Sat Apr 16 07:44:21 MST 2011

Quote:

...stand alone...

Without LPC-Link? In release mode? Without semihosting? Could you provide more details please?
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by g9010086 on Sat Apr 16 05:32:40 MST 2011
Hi,

I am using the RDB1768cmsis_efsl_demo on the LPC1768 Xpresso board. When reading a file in debug mode the code works fine. But when i run it stand alone the file does not seem to be read?
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Thu Apr 07 08:51:42 MST 2011

Quote: Zero
Yes, 25MHz (LPC1768 & 1GB Platinum Micro SD)  :)

Don't know which SD you are using, usually for higher speeds (up to 100MHz) 4-bit SD mode is required. So if you use SPI mode you're limited to 25MHz :mad:



Using SD in native mode would be the most elegant and fastest but SPI is much simpler for use with MCUs.  It would be nice if SPI could achieve those speeds.:(

Zero, how is your hardware set up?  Is it a PCB?
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Apr 07 06:57:28 MST 2011

Quote:

Have somebody been able to interface sd cadrs via lpcxpresso with spi clk speed grerater than 12Mhz...


Yes, 25MHz (LPC1768 & 1GB Platinum Micro SD)  :)

Quote:

...As far as i know the micro sd card I'am using can achieve much greater speeds.


Don't know which SD you are using, usually for higher speeds (up to 100MHz) 4-bit SD mode is required. So if you use SPI mode you're limited to 25MHz :mad:
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bobi-one on Wed Apr 06 00:50:04 MST 2011

Quote: larryvc


bobi-one make sure you have very short leads.  Good caps across power and ground at the SD connector got me about 16 MHZ on a breadboard.  I am using an adafruit SD Breakout Board+ which is buffered.



oops , the wires to the sd card ar at least 10cm, and there is spi touch screen controller  also connected to the spi( it uses different spi initialisation for slower clock)
which goes to my next question. Is it bad to switch clock speed so often  for the spi depending which slave is selected at the moment?
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Tue Apr 05 22:09:28 MST 2011

Quote: jharwood
Please read my previous post.



Oops, Sorry.  Where is my calculator when I need it?:o

I knew about the slow/fast changeover but the formula didn't make it from my I/O buffer to my brain correctly.:)
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Tue Apr 05 21:53:22 MST 2011

Quote: larryvc
jharwood is this supposed to be 7,200,000 or 72,000,000 ? 

/* (PCLK / (CPSDVSR — [SCR+1])) = (7,200,000 / (2 x [8 + 1])) = 400 KHz */




Please read my previous post.
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Tue Apr 05 20:47:11 MST 2011
jharwood is this supposed to be 7,200,000 or 72,000,000 ? 

/* (PCLK / (CPSDVSR — [SCR+1])) = (7,200,000 / (2 x [8 + 1])) = 400 KHz */

bobi-one make sure you have very short leads.  Good caps across power and ground at the SD connector got me about 16 MHZ on a breadboard.  I am using an adafruit MicroSD Card Breakout Board+ which is buffered.

I'm hoping to get that number up on a PCB.
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Tue Apr 05 17:49:21 MST 2011
SD Specifications Part A2 SD Host Controller Simplified Specification Version 3.00:

http://www.sdcard.org/developers/tech/pls/simplified_specs/Part_A2_SD_Host_Controller_Simplified_Spe...
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Tue Apr 05 17:14:10 MST 2011
The following worked for me:

    if (clk_speed == SSP_SLOW)
        /* (PCLK / (CPSDVSR — [SCR+1])) = (7,200,000 / (2 x [8 + 1])) = 400 KHz */
        LPC_SYSCON->SSPCLKDIV = 10; /* Divided by 10 */
    else
        /* (PCLK / (CPSDVSR — [SCR+1])) = (72,000,000 / (2 * [1 + 1])) = 18.0 MHz */
        LPC_SYSCON->SSPCLKDIV = 1; /* Divided by 1 */

...

    if (clk_speed == SSP_SLOW) {
        /* Set DSS data to 8-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 8 */
        LPC_SSP->CR0 = 0x0807;
    } else {
        /* Set DSS data to 8-bit, Frame format SPI, CPOL = 0, CPHA = 0, and SCR is 1 */
        LPC_SSP->CR0 = 0x0107;
    }
    /* SSPCPSR clock prescale register, master mode, minimum divisor is 0x02 */
    LPC_SSP->CPSR = 0x2;

The slow speed is used during card initialization, then it switches to high speed once initialization is complete. I haven't tried going up to 24Mhz, but it should work. And I hear that Sandisk cards can run at up to 50Mhz.
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bobi-one on Tue Apr 05 16:01:30 MST 2011
i am developing my  board, but as a start I'm using lpc xpresso with lpc1343 + micro sd connector directly to the spi pins
0 Kudos

2,178 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by larryvc on Tue Apr 05 09:42:24 MST 2011
What is your hardware setup?  ie.  LPCxxxx, baseboard, your own design, breadboard
0 Kudos