This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Disabling/enabling SPI Pins for SD Card

I want to save Power by disabling the SD Card. VCC of the card is already regulated with an external MOSFET switch and controlled by a pin of the nRF. The problem now is, that the SPI data lines still power the SD Card. Therefore, I want to disable them. Is this possible, without having to redo the initialisation process of the SD Card? By the initialisation process I mean the following:

	/**
* @brief  SDC block device definition
* */
NRF_BLOCK_DEV_SDC_DEFINE(
    m_block_dev_sdc,
    NRF_BLOCK_DEV_SDC_CONFIG(
            SDC_SECTOR_SIZE,
            APP_SDCARD_CONFIG(SDC_MOSI_PIN, SDC_MISO_PIN, SDC_SCK_PIN, SDC_CS_PIN)
     ),
     NFR_BLOCK_DEV_INFO_CONFIG("Nordic", "SDC", "1.00")
);
static diskio_blkdev_t drives[] = {
      DISKIO_BLOCKDEV_CONFIG(NRF_BLOCKDEV_BASE_ADDR(m_block_dev_sdc, block_dev), NULL)  };

diskio_blockdev_register(drives, ARRAY_SIZE(drives));

NRF_LOG_INFO("Initializing disk 0 (SDC)...\r\n");


for (uint32_t retries = 3; retries && disk_state; --retries)
{
      disk_state = disk_initialize(0);
}
if(disk_state)
{
     NRF_LOG_INFO("Disk initialization failed.\r\n");
     return false;
}
Parents
  • It is also a mystery to me, why there is still a voltage at the vcc line. But still, I want to disconnect the pins, in order to save power anyhow. But maybe I have to look into my mosfet switch again... I am using the SPI peripheral (SDK 12.3). The disconnect works fine. But now I have problems with enabling it again. I enable the pins like this:

     NRF_SPI1->PSEL.SCK = SDC_SCK_PIN | 0x80000000;
    	NRF_SPI1->PSEL.MISO = SDC_MISO_PIN | 0x80000000;
    	NRF_SPI1->PSEL.MOSI = SDC_MOSI_PIN | 0x80000000;
    

    Is that correct? If I then use the function:

       if (f_mount(&Fatfs,"/",1) != FR_OK)
      {
    		NRF_LOG_INFO("Mount failed.\r\n");
    		return;
      }
    

    It gets stuck in the default_wait_func(void) function in the file diskio_blkdev.c and stays there forever. Am I doing something wrong when reconnecting the pin or do I need to initialize the card again (as shown in the first question)?

Reply
  • It is also a mystery to me, why there is still a voltage at the vcc line. But still, I want to disconnect the pins, in order to save power anyhow. But maybe I have to look into my mosfet switch again... I am using the SPI peripheral (SDK 12.3). The disconnect works fine. But now I have problems with enabling it again. I enable the pins like this:

     NRF_SPI1->PSEL.SCK = SDC_SCK_PIN | 0x80000000;
    	NRF_SPI1->PSEL.MISO = SDC_MISO_PIN | 0x80000000;
    	NRF_SPI1->PSEL.MOSI = SDC_MOSI_PIN | 0x80000000;
    

    Is that correct? If I then use the function:

       if (f_mount(&Fatfs,"/",1) != FR_OK)
      {
    		NRF_LOG_INFO("Mount failed.\r\n");
    		return;
      }
    

    It gets stuck in the default_wait_func(void) function in the file diskio_blkdev.c and stays there forever. Am I doing something wrong when reconnecting the pin or do I need to initialize the card again (as shown in the first question)?

Children
Related