Discussion in "8051 Discussion Forum" started by    zachsmthsn    Apr 24, 2013.
Wed Apr 24 2013, 12:20 AM
#1
Hi all,

I am working on a project where I will be using an SD card to store sensor data and transmitting this data using an FTP to an iPhone app. The FTP is already developed and plans on using the SD card as a buffer. That is, the data will be sampled, and saved to an SD card. When a reading has completed, the data will be sent to the iPhone using the FTP that has been developed to send up to 20 kB files using 20 byte packets. What I need to do now is set up the SD card to be accessed using the SPI interface.

I have very little experience with this, but have been using the tutorial found on this website. (http://www.8051projects.net/mmc-sd-interface-fat16/) I seem to understand most everything in it, but am quite confused on the functions he talks about from pages 8-13. I understand their function and what is going on but I'm really not sure where they are being used. I feel like they have to be either added on to tff.c (I am actually using the petite version, though) or declared somewhere as deep, because they are used in the diskio.c to initialize everything and read/write to the SD card. If they are added to the tff.c file, the tff.h file would need to be modified (if I'm not mistaken) and I would think that this would have been addressed if it was the correct approach. It really is described more like these are functions you will be using to interface with this library, but I highly doubt that since they are used in the diskio.c file.

Thank you for any help you might be able to provide on this, and I might be coming back to this thread for more help. This was a last minute idea as a buffer for my senior design project, and the demo is next Thursday!
Thu Apr 25 2013, 04:51 AM
#2
Thanks for posting your doubt, Its fairly possible for a new user to learn about such abstract library. When I say abstract I mean library is written in a modular way such that it can be easily ported to different platforms and different storage media like SD card, hard drives etc. If your storage media changes driver will also change. Modular way of writing code ensures that any low level hardware change does not effect actual code which is hardware independent. So coders always write a small interface layer which is common to hardware independent code. In this case diskio.c is that layer.

All the top level function calls that deal with sd card goes to diskio.c which does your basic initialization of card, read and write operations. When you are working with petitfs you do not have tff.c file so I am not going to talk about it here. Its only pff.c which is as I said a hardware independent code. So neither tff nor pff.c needs to be modified.

diskio.c in petitfs package has skeleton functions which you need to fill up. Like disk_initialize, partial sector read, partial sector write.

Refer to SD Init for disk initialize:
http://www.8051projects.net/mmc-sd-interface-fat16/sd-card-initialization.php

Refer to SD Sector read/write:
http://www.8051projects.net/mmc-sd-interface-fat16/reading-writing-sd-mmc-sector.php

Also refer to diskio.c mentioned here where most of your functions calls will go:
http://www.8051projects.net/mmc-sd-interface-fat16/disk-io-functions.php

SPI related function will be replaced by your hardware spi functions. I did work on these myself. I might find something on my PC at home that I can share later on.

Do let us know if you still need anymore help.
Tags petitfsfatfselm-chan fatfsfat32fat16fat filesystemworking with fatfs8051 fat filesystem

Get Social

Information

Powered by e107 Forum System

Conversation

No messages yet.

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 145, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123