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.

[ARM] SD card using FAT file and File i/o libraries

Status
Not open for further replies.

shankarrg

Newbie level 6
Joined
Jun 6, 2017
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
150
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,
 

Chan's FatFs library is definitely the best option.
 

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();
}
 

Attachments

  • sdcard.7z
    50.3 KB · Views: 106
Last edited by a moderator:

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
 

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
 

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.
 

I am trying SD card using DMA interface.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top