+ Post New Thread
Results 1 to 8 of 8
  1. #1
    Newbie level 6
    Points: 147, Level: 1

    Join Date
    Jun 2017
    Posts
    11
    Helped
    0 / 0
    Points
    147
    Level
    1

    SD card using FAT file and File i/o libraries

    Hello,

    I am interfacing SD card on ARM: LPC3250, I am able to read write single sector.Now i am trying FAT16 with 2GB card.

    PROBLEM: I googled, getting FAT library without application I/o (I mean without File operation File_open, File_read etc..) libraries. I tried few FAT16 library it is pointing to dummy file operation definition or through SPI(I am not using SPI).

    Please suggest any links to FAT with file operation libraries/ open source code.

    Thanks,

    •   Alt13th September 2017, 14:46

      advertising

        
       

  2. #2
    Advanced Member level 4
    Points: 8,031, Level: 21
    Easyrider83's Avatar
    Join Date
    Oct 2011
    Location
    Tallinn, Estonia
    Posts
    1,440
    Helped
    330 / 330
    Points
    8,031
    Level
    21

    Re: SD card using FAT file and File i/o libraries

    Love me or hate me. All infractions will be ignored.


    1 members found this post helpful.

  3. #3
    Newbie level 4
    Points: 89, Level: 1

    Join Date
    Jul 2017
    Posts
    6
    Helped
    1 / 1
    Points
    89
    Level
    1

    Re: SD card using FAT file and File i/o libraries

    Chan's FatFs library is definitely the best option.



    •   Alt15th September 2017, 20:27

      advertising

        
       

  4. #4
    Newbie level 6
    Points: 147, Level: 1

    Join Date
    Jun 2017
    Posts
    11
    Helped
    0 / 0
    Points
    147
    Level
    1

    Files in SD card getting deleted after write single block

    Hello All,

    I am interfacing SD card on ARM: LPC3250, I am able to read write single sector.Now i am trying FAT16 with 2GB card using Chan's FatFs library.

    I read 512 bytes from Doc1.txt and trying to overwrite 512 bytes of Doc2.txt.

    Problem is after writing i am facing below issue:
    1) Some times file in SD card deleted.
    2) It asking for SD card format.
    3) Not responding to command deselect or put card to to Idle.

    When i open SD card in hexa editor data is written but root directory size of file is not updated and MBR is replaced by BOOT Sector.

    Code snippet below and attached the files i am working. Please suggest what am i missing .
    Code:
    void c_entry(void)
    {
    	
     ............
    
    	/* Read Doc1.txt */
    	str_copy(&pFileName,"Doc1.txt");
    
    	f_mount (fs, "", 0);        
    	retres = f_open(&filp,pFileName, FA_READ);
    
    	if(retres == FR_OK)
    	{
    		f_read(&filp,pbuff,512,&bytesread);
    	}
    
    	/* write Doc2.txt */
    	str_copy(&pFileName,"Doc2.txt");
    	bytesread = 0;
    
    	retres = f_open(&filpw,pFileName, (FA_READ | FA_WRITE));
    
    	if(retres == FR_OK)
    	{
    		f_write(&filpw,pbuff,512,&bytesread);
    	}
    	retres = f_close(&filp);
    	retres = f_close(&filpw);
    
    	/* Deselect card */
    	sdmmc_cmd_send(SDMMC_SELECT_CARD, 0, &resp);
    
    	/* Place card into idle to shut it down */
    	sdmmc_cmd_send(SDMMC_IDLE, 0, &resp);
    
    	sdmmc_close();
    
    	/* Enable SDMMC power */
    	phy3250_sdpower_enable(FALSE);
    
    	/* Disable interrupts in ARM core */
    	disable_irq_fiq();
    }
    Last edited by FvM; 30th October 2017 at 08:34. Reason: Merged with previous SD-Card thread



  5. #5
    Newbie level 6
    Points: 147, Level: 1

    Join Date
    Jun 2017
    Posts
    11
    Helped
    0 / 0
    Points
    147
    Level
    1

    Read and write from SD card using DMA Controller

    Hello,

    I have interfaced SD-CARD with ARM-LPC Raw read and write working well with FAT. Now I want introduce DMA for read and write to avoid CPU.

    Please suggest how to read and write from SD card using DMA Controller.

    Thanks



  6. #6
    Newbie level 6
    Points: 147, Level: 1

    Join Date
    Jun 2017
    Posts
    11
    Helped
    0 / 0
    Points
    147
    Level
    1

    DMA Sequence to Read SD card

    Hello,

    Reading and writing SD card using DMA requires bus interface like SPI?
    I want to read and write SD card using DMA without SPI is it possible?

    I tried to read first sector of from SD card through DMA channel 0 but not succeed. I enabled channel 0 trying to read first sector of SD card(Sector Zero).
    Source address i mentioned Zero am i correct ?

    Code:
    dma_src = 0x0;
    dma_dest= (UNS_32)databuff;
    next_lli = 0x0;
    next_ctrl= 0x0;
    config_ch = 0x1;
    Please suggest/help.
    The sequence of read and write from SD card using DMA Controller(I am using ARM LPC)

    Thanks



    •   AltYesterday, 06:54

      advertising

        
       

  7. #7
    Super Moderator
    Points: 236,483, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    40,900
    Helped
    12499 / 12499
    Points
    236,483
    Level
    100

    Re: SD card using FAT file and File i/o libraries

    SD card can be interfaced either through dedicated SD card interface (fast access with 4 data lines) or SPI interface.

    In any case, the used interface has to be set up respectively. It's not clear which interface should be addressed by your code snippet.



  8. #8
    Newbie level 6
    Points: 147, Level: 1

    Join Date
    Jun 2017
    Posts
    11
    Helped
    0 / 0
    Points
    147
    Level
    1

    Re: SD card using FAT file and File i/o libraries

    I am trying SD card using DMA interface.



--[[ ]]--