• AVR Freaks

Helpful ReplyHot!FAT32 formatted SDHC card interfacing with PIC32MX

Author
BHUSHAN
Starting Member
  • Total Posts : 62
  • Reward points : 0
  • Joined: 2019/02/04 23:17:18
  • Location: 0
  • Status: online
2019/07/17 03:47:09 (permalink)
0

FAT32 formatted SDHC card interfacing with PIC32MX

Hi 2 All
I am using PIC32MX795F512L to interface with FAT32 formatted SDHC card. I am attaching my project files with this post.
 I am creating a file and entering its attributes in the directory of FAT32,  also  writing to free clusters as pointed by FSinfo_structure. I am also able to read the data of created file using my "ReadFile" function. Problem arises when I try to read created file using my PC. On PC,file name is visible but when I try to open the file using Notepad or WordPad then I am getting the error message that ".....file is not found". Kindly suggest me what is wrong. (Right now I am just writing and reading 1 sector ie 512 bytes).
 
#1
TS9
Super Member
  • Total Posts : 782
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/17 04:39:28 (permalink)
0
Which Harmony or MLA verison you are using?
#2
BHUSHAN
Starting Member
  • Total Posts : 62
  • Reward points : 0
  • Joined: 2019/02/04 23:17:18
  • Location: 0
  • Status: online
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/17 05:21:30 (permalink)
0
TS9
Which Harmony or MLA verison you are using?

I am using PIC32MX795F512L custom board. MPLABX ide v5.10.
#3
ric
Super Member
  • Total Posts : 23185
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/17 06:30:42 (permalink)
4 (1)
That did not answer the question that TS9 asked.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#4
TS9
Super Member
  • Total Posts : 782
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/17 07:10:06 (permalink)
4 (1)
ric
That did not answer the question that TS9 asked. 

Please answer correct ... without wasting other's precious time.
#5
BHUSHAN
Starting Member
  • Total Posts : 62
  • Reward points : 0
  • Joined: 2019/02/04 23:17:18
  • Location: 0
  • Status: online
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/17 21:29:23 (permalink)
0
TS9
ric
That did not answer the question that TS9 asked. 

Please answer correct ... without wasting other's precious time.



Sorry, but untill now I didn't know the meaning of MLA and Harmony. Anyway I am not using either of them.
#6
Memen
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2017/04/08 12:17:32
  • Location: 0
  • Status: offline
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/18 01:18:17 (permalink) ☄ Helpfulby BHUSHAN 2019/07/18 03:15:55
5 (1)
Why not use FatFS file system? http://elm-chan.org/fsw/ff/00index_e.html
It only requires you to implement certain low level functions (which you already seem to have), and the rest is taken care of.
 
Best regards,
#7
TS9
Super Member
  • Total Posts : 782
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/18 04:02:02 (permalink)
0
Memen
Why not use FatFS file system? http://elm-chan.org/fsw/ff/00index_e.htmlIt only requires you to implement certain low level functions (which you already seem to have), and the rest is taken care of. Best regards,


That are also implemented in the code in below thread:


https://www.microchip.com...aspx?m=563218&fp=3


--
TS9
#8
BHUSHAN
Starting Member
  • Total Posts : 62
  • Reward points : 0
  • Joined: 2019/02/04 23:17:18
  • Location: 0
  • Status: online
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/18 05:01:56 (permalink)
0
TS9
Memen
Why not use FatFS file system? http://elm-chan.org/fsw/ff/00index_e.htmlIt only requires you to implement certain low level functions (which you already seem to have), and the rest is taken care of. Best regards,


That are also implemented in the code in below thread:


https://www.microchip.com...aspx?m=563218&fp=3


--
TS9

I am avoiding any overhead libraries due to memory constraints as my project may consume majority of Flash memory of PIC32MX(as Project proceeds). 
#9
TS9
Super Member
  • Total Posts : 782
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/18 10:09:08 (permalink)
4 (1)
Using libraries will easy your task for application development.

As you said you have limited memory.

You should use PIC32MZ or PIC32MK processor.
#10
Memen
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2017/04/08 12:17:32
  • Location: 0
  • Status: offline
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/18 10:32:26 (permalink)
0
To add on that, this 'library' is relatively small (since it is designed to be used in embedded systems), and it contains the c code itself, so you can make it as efficient (for memory) as you like by e.g. using compiler with -Ox options or simply removing functions you do not use from the source. I think it will save you a lot of time checking this 'library' out!
 
Did you try and create a file on pc, then read it with the pic32?
#11
BHUSHAN
Starting Member
  • Total Posts : 62
  • Reward points : 0
  • Joined: 2019/02/04 23:17:18
  • Location: 0
  • Status: online
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/18 21:36:00 (permalink)
0
Memen
To add on that, this 'library' is relatively small (since it is designed to be used in embedded systems), and it contains the c code itself, so you can make it as efficient (for memory) as you like by e.g. using compiler with -Ox options or simply removing functions you do not use from the source. I think it will save you a lot of time checking this 'library' out!
 
Did you try and create a file on pc, then read it with the pic32?


Yes,I am able to successfully read the contents of a file created on PC using PIC32. I am doing wrong while creating a new file(I found that I am not writing 0x0fffffff to file allocation table sector corresponding to file related cluster number). I am working on it and will let you know.
Thanks for your cooperation(it motivates to keep going).
#12
BHUSHAN
Starting Member
  • Total Posts : 62
  • Reward points : 0
  • Joined: 2019/02/04 23:17:18
  • Location: 0
  • Status: online
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/22 03:16:27 (permalink)
0
Hi!
I am facing one issue which I am not able to understand. I am creating new text files on FAT32 formatted SDHC card using my PC and checking the Root Directory sector using WinHex software. I found that whenever I create a new file, an automatic insertion happens between previous and new entries in Root Directory sector.
It looks like a new text document entry.I have attached the image of WinHex software. As you can see that files created by me are highlighted using yellow while an automatic entry was bracketed between red brackets. Why this automatic entry is occuring?
 

Attached Image(s)

#13
ric
Super Member
  • Total Posts : 23185
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/22 03:23:40 (permalink)
5 (1)
HOW are you "creating a new text document" ?
My guess is you are using a text editor, and it is creating a temporary file named "New Text Document.txt".
Then you are saving it using "Save As" to set a new name, so it writes the final version to the new name, and deletes the temporary version. You are seeing the deleted name.
This comes down to the behaviour of your text editor, not the file system.
 
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#14
BHUSHAN
Starting Member
  • Total Posts : 62
  • Reward points : 0
  • Joined: 2019/02/04 23:17:18
  • Location: 0
  • Status: online
Re: FAT32 formatted SDHC card interfacing with PIC32MX 2019/07/22 03:31:48 (permalink)
0
ric
HOW are you "creating a new text document" ?
My guess is you are using a text editor, and it is creating a temporary file named "New Text Document.txt".
Then you are saving it using "Save As" to set a new name, so it writes the final version to the new name, and deletes the temporary version. You are seeing the deleted name.
This comes down to the behaviour of your text editor, not the file system.
 
 




Bull's eye. You got it absolutely right.
Thanks
#15
Jump to:
© 2019 APG vNext Commercial Version 4.5