Category:SD Library

From Pinguino
Jump to: navigation, search


The SD Library and its functions aim at allowing users to read from and write to SD cards, either using the micro SD slot included on some boards or potentially using an external SD card connector.

The SD library makes use of FatFS Generic FAT Files system module (R0.09, Sep 06, 2011) together with other library files written or customised to work in the Pinguino environment.

As at 6 May 2012 this library is being modified to extend its functionality to cover the PIC32 Pinguino Micro board - have a look at the Pinguino Forum to find out current progress. When those changes have been completed the updated library will be available from the SVN repository and this wiki page updated accordingly.

Compatible Boards/Compatibility

Boards with RTCC

  • PIC32 Pinguino OTG
  • PIC32 Pinguino

Boards without RTCC

  • PIC32 Pinguino Micro
Any board not specifically listed under "Boards with RTCC" above will behave as if it does not have RTCC.
(see Known Limitations/Bugs below)

How to Use/Include

The SD library uses a Serial Peripheral Interface (SPI) bus to "talk" to the SD card. The SPI bus specifies four logic signals:

  • SCLK: serial clock (output from master);
  • MOSI: master output, slave input (output from master);
  • MISO: master input, slave output (output from slave);
  • SS: slave select (active low, output from master).

The SD library uses the standard PIC32 connections for SPI2 for SCLK, MOSI and MISO but uses a separate connection for SS, not #SS2. This allows the SD card to be addressed separately from other devices connected to SPI2 and the SD.mount() function is used to tell the SD library which connection is being used.

SD Card Connections
SPI microSD Card PIC32
SS 2 = CD/DAT3/CS set by SD.mount( )

Where the SD card connector is on the board the Pinguino Pin number used in the SD.mount() function is determined by the hardwired connections on the board (see below).

SD.mount values for supported boards
PIC32 Pinguino SD.mount(8);
PIC32 Pinguino OTG SD.mount(8);
PIC32 Pinguino Micro SD.mount(40);


Known Limitations/Bugs

For boards with RTCC
The RTCC needs to have been set before writing files or directories/folders to the SD card for the date/time stamp to be correct and the RTCC to function correctly.
For boards without RTCC
When files or directories/folders are written to the SD card a default date and time of 01 Jan 2012 12:00:00 is used for the date/time stamp so all files or directories/folders written to the card using the SD library will have the same date and time.

Other Comments/Suggestions

Corrections, suggestions, and new documentation can be made directly on this Wiki

Library Functions

This category currently contains no pages or media.