This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Unable to mount the sd card in lpc1768

I am working on file system middleware component to interface the SD card with lpc1768.I double checked all the resource requirements and configuraton of all the components required.Still, fmount function returns the fsMediaError and is unable to amount the memory drive.I have no clue of the issue. Can anyone please help me out on this ?

Am using the code given below to initialize and mount the sd card.

void sd_init(void)
{fsStatus stat;
SystemInit();
        LPC_GPIO2->FIODIR=0XFFFFFFFF;
  printf ("Initializing and mounting enabled drives...\n\n");

  /* Initialize and mount drive "M0" */
  stat = finit ("M0:");
  if (stat == fsOK) {
    stat = fmount ("M0:");
      if (stat == fsOK) {
       LPC_GPIO2->FIOPIN=0xfffffff1;
                        printf ("Drive M0 ready!\n");
    }
    else if (stat == fsNoFileSystem) {
        /* Format the drive */
     LPC_GPIO2->FIOPIN=0xfffffff2;
                        printf ("Drive M0 not formatted!\n");

    }
    else if (stat==fsMmediaError){
      printf ("Drive M0 mount failed with error code %d\n", stat);
     LPC_GPIO2->FIOPIN=0xfffffff3;
                }
  }
  else {
    printf ("Drive M0 initialization failed!\n");
  }
 printf ("\nDone!\n");
                }

Parents
  • Yes, if you mean in the CS code, have tried both.

    still no difference.

    I am sure i am missing something silly, this has been puzzling me for about 70 hours at this point.

    int32_t fs_mc_spi_control_ss (uint32_t drive_num, uint32_t ss){
            if (ss==0) HAL_GPIO_WritePin(GPIOD,GPIO_PIN_3,GPIO_PIN_SET);
              else HAL_GPIO_WritePin(GPIOD,GPIO_PIN_3,GPIO_PIN_RESET);
            return ss;
    }
    

    about ready to give up and continue on with the Mikroelektronika, where I have written FTP, HTTP, SD Card logging etc. Went to keil as I thought they had built in functions etc and I would like to use the RTOS.

Reply
  • Yes, if you mean in the CS code, have tried both.

    still no difference.

    I am sure i am missing something silly, this has been puzzling me for about 70 hours at this point.

    int32_t fs_mc_spi_control_ss (uint32_t drive_num, uint32_t ss){
            if (ss==0) HAL_GPIO_WritePin(GPIOD,GPIO_PIN_3,GPIO_PIN_SET);
              else HAL_GPIO_WritePin(GPIOD,GPIO_PIN_3,GPIO_PIN_RESET);
            return ss;
    }
    

    about ready to give up and continue on with the Mikroelektronika, where I have written FTP, HTTP, SD Card logging etc. Went to keil as I thought they had built in functions etc and I would like to use the RTOS.

Children