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 a SPI interface, but have found a tutorial using a modified 8052 (http://www.8051projects.net/mmc-sd-interface-fat16/MMC-SD-Card-interfacing-and-FAT16-Filesystem.pdf) that will help once I figure out how to get everything initialized. This is using the elm-chan fat16 library to write to an external SD card (http://elm-chan.org/fsw/ff/00index_e.html).
This initialization is gone over in the tutorial, but it is for his uC which is a upsd3334D, based on the 8052. The issues he addresses with initialization include setting up the chip select line to be manually controlled, rather than having the CC2540 turn on the CS line whenever the SPI is active, and turn it off when it is inactive. I am too inexperienced to tell you why this is important, so I will probably have to trust the writer of the tutorial that is is indeed important. I also need to know how to set the frequency for the SPI clock. I know this comes from the baud rate, but I have no idea what relevant frequencies exist. He uses 4 frequencies (400k, 1M, 5M, 10M) and this has something to do with the current operation of the SD card and is related to the crystal oscillator frequency. He also defines a few mode of operation values which are Transmitter Enable, Receiver Enable, SPI enable, Slave Selection, First LSB, Sampling polarity. I have no idea why these are defined manually, since I have defined the pins to be used with a SPI interface already (I think) using the UxCSR.MODE which sets the SPI mode as active, and from the user manual, seems to set UxCSR.ACTIVE to high whenever the SPI interface is active. But I may be misunderstanding this .
Any help that may be offered to manually define these mode variables and control my chip select line manually would be greatly appreciated. It also doesn't help that I am using a BlueRadios BR-LE4.0-S2A chip which has been developed from the CC2540, so I am having even further translation issues between user guides.
Thanks,
Zach