Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

help to write in 2G sd card with arm at91sam7s64 via spi

Status
Not open for further replies.

mehdi8310021

Newbie level 2
Joined
Mar 13, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,290
hi
i can to write in 1G byte sd card with arm at91sam7s64 via spi. but when i chance it with 2G byte sd cart it does not work.:-(
in initializing sd in 1G byte when arm sents 0x00 to sd the 0x01 respond returns from sd but in 2G byte sd cart the 0xFF respond returns from sd.
this is my codes in spi and mmc/sd initialization
thanks for your think

PHP:
[CODE]void initSPI (void)
{
  
  //PA.11 -> NPCS0
  //PA.12 -> MISO
  //PA.13 -> MOSI
  //PA.14 -> SPCK
  s_pPio->PIO_PDR = BIT11 | BIT12 | BIT13 | BIT14;
  s_pPio->PIO_ASR = BIT11 | BIT12 | BIT13 | BIT14;
  s_pPio->PIO_BSR = 0;
  AT91C_BASE_PMC->PMC_PCER=1<<AT91C_ID_SPI;

    // pull up resistor
  s_pSys->PIOA_PPUER = BIT11 | BIT12 | BIT13;

  //s_pPMC->PMC_PCER = AT91C_ID_SPI;        //enable the clock of SPI
  s_pPMC->PMC_PCER = 1 << AT91C_ID_SPI;

  /****  Fixed mode ****/
  s_pSpi->SPI_CR      = 0x81;              //SPI Enable, Sowtware reset
  s_pSpi->SPI_CR      = 0x01;              //SPI Enable


  s_pSpi->SPI_MR      = 0xE0011;          //Master mode, fixed select, disable decoder, FDIV=0 (MCK), PCS=1110
  s_pSpi->SPI_CSR[0]  = 0x0802;           //8bit, CPOL=0, ClockPhase=1, SCLK = 200kHz
 // s_pSpi->SPI_CSR[0]  = 0x0202;           //8bit, CPOL=0, ClockPhase=1, SCLK = Max

#ifdef SPI_PDC_Transfer_Mode
  s_pPDC->PDC_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTEN;
#endif
  s_pSpi->SPI_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTEN;
}



// Initialization
char initMMC (void)
{

  //raise SS and MOSI for 80 clock cycles
  // >>> SendByte(0xff) 10 times with SS high
  //RAISE SS
 
  char response=0x01;


//  dbgu_print_ascii("Start iniMMC......");
  initSPI();
  //initialization sequence on PowerUp
 //CS_HIGH();

  for(int i=0;i<=18;i++)
    spiSendByte(0xff);
  //CS_LOW();
  //Send Command 0 to put MMC in SPI mode
  for(int i=0;i<=19;i++){
  mmcSendCmd(0x00,0,0x95);
  if(mmcGetResponse()==0x01){
    /*222222222  glcd_Text(5,31, FONT_SEVEN_DOT,"yes Responses");
      glcd_UpdateAll();*/
    break;
  }
  
  
   if(i>=0x18){
      
      /* 11111111111 for(int h=0;h<=19;h++){
        glcd_Text(5,31, FONT_SEVEN_DOT,"No Response");
      glcd_UpdateAll();
        h=h+1;
      }*/
  }
  }
 
  
  //Now wait for READY RESPONSE
  

  while(response==0x01)
  {
//   dbgu_print_ascii("Sending Command 1");
    /* 11111111111 glcd_Text(5,15, FONT_SEVEN_DOT,"Sending Command 1");
     glcd_UpdateAll();*/
   //CS_HIGH();
   spiSendByte(0xff);
   //CS_LOW();
   mmcSendCmd(0x01,0x00,0xff);
   response=mmcGetResponse();
  }
  //CS_HIGH();
  spiSendByte(0xff);
   glcd_Text(5,18, FONT_SEVEN_DOT,"MMC INITIALIZED");
      glcd_UpdateAll();  
//  dbgu_print_ascii("MMC INITIALIZED AND SET TO SPI MODE PROPERLY.");
  return MMC_SUCCESS;
}[/CODE]
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top