Secure Digital SD Card Source Code Driver Project
Section 11. Revision History

11. Revision History

a) Changes To The MMC / SD Memory Card Driver Files

V1.10

Direct support added for CrossWorks for ARM compiler using NXP 32bit Arm micro.

FFS_CE output pin definition modified to support pin set and pin clear registers where needed.

Added ffs_change_file_size() function.

The ffs_check_command_response_byte function relied on the last response value being retained in FFS_SPI_RX_BYTE_BUFFER as the value was read again and tested by various functions which called ffs_check_command_response_byte. This is not suitable for microcontrollers that have a fifo buffer on the SPI port receive. Changed to use a new global variable called chk_cmd_response_data in which the FFS_SPI_RX_BYTE_BUFFER value is stored and which the calling functions instead use to test with.

It has been found in some circumstances that corruption issues can be solved by replacing the following occurrences:

	while (FFC_DI == 0)
		ffs_read_byte();

with this:

	ffs_read_byte();
	while (FFC_DI == 0)
		ffs_read_byte();

The cause of this is unknown as the specification does not appear to require this, but it does not prohibit it either so it is sensible to include.

Added the following at the end of ffs_flush:


	//----- ENSURE CARD HAS COMPLETED LAST WRITE PROCESS -----
	//When closing a file if the last write to the card before it is removed or powered down just occurred
	//some cards have been found to not store the last sector written.  If the card is flagging that its busy
	//then provide clock pulses to allow it to complete its last operation
	DO_BUSY_STATE_ACCESS_DELAY;
	FFS_CE(0);								//Select the card
	DO_BUSY_STATE_ACCESS_DELAY;
	ffs_read_byte();
	while (FFC_DI == 0)
		ffs_read_byte();
	FFS_CE(1);								//Deselect the card
	return(0);

Removed the ENSURE CARD HAS COMPLETED LAST WRITE PROCESS section from ffs_fclose as this is now provided by ffs_flush.

ffs_read_sector_to_buffer function modified to include retry if the read fails to deal with rare cards found to not action the command if busy whilst not actually flagging that they are busy.

ffs_write_sector_from_buffer function modified to include retry if the read fails to deal with rare cards found to not action the command if busy whilst not actually flagging that they are busy..

ffs_remove function updated to ensure both FAT tables are updated.

Issue fixed in ffs_fputc where overwriting within a file across a cluster boundary could cause corruption.

In mem-ffs.c changed:

bytes_to_new_posn -= (DWORD)0 – offset;

to be

bytes_to_new_posn -= (DWORD)(0 – offset);

as this solved a “unary minus operator applied to unsigned type” error with the Codewarrior compiler.

V1.11

In ffs_write_sector_from_buffer the line:

    buffer_pointer = &FFS_DRIVER_GEN_512_BYTE_BUFFER[0];

to be inside the while loop in case card returns error at the very end of the write operation.

In ffs_change_file_size and ffs_remove changed the line:

dw_temp = (next_cluster / fat_entries_per_sector);	//dw_temp now has the sector address that will need to be modifed for the next cluster entry

to be:

    dw_temp = (read_cluster_number / fat_entries_per_sector);	//dw_temp now has the sector address that will need to be modifed for this cluster entry

to correct possible memory corruption bug

Microchip PIC32 support added to driver

V1.12

ffs_remove() function re-written to fix issue with FAT table updating.

Updated this line in mem-mmcsd.c as on fast systems with some cards a longer timeout has been found to be necessary:


	//Wait for data token
	for (count = 100; count > 0; count--)

to be:


	//Wait for data token
	for (count = 1000; count > 0; count--)

b) Changes To The Sample Project Files

V1.10

NXP LPC2365 ARM sample project added.

V1.11

No changes to sample project

V1.12

No changes to sample project

c) Special Note Regarding SPI Bus

Please see the:

‘Signal Noise Issues With MMC & SD Memory Cards (& Clocked Devices In General)

page in the resources area of our web site for details of a common problem experienced when using MMC and SD memory cards. Some manufacturers demo / evaluation boards have been found to suffer from this issue.

Many of the PIC microcontrollers have silicon bug issues that are detailed in the Microchip errata sheets. If you are experiencing problems with a PIC microcontroller accessing cards check the errata sheet for the device you are using.

d) Changes To The Technical Manual

V1.00

Original release

V1.01

Added sections on ‘Fast Reading Of Bulk File Data’ and ‘Fast Writing Of Bulk File Data’.

Added ‘Searching In The Directory’ section to demonstrate how it is possible to search in the root directory for files.

V1.02

Updated schematic for PIC18 sample project at the end of this manual with correction to PIC pinning to match sample project code.

V1.03

Updated Driver Technical Overview section with explanation of using SD cards with capacities above 1GB and with the addition of SDHC and MMC Plus high capacity card compatibility.

Minor additions to other sections of the manual.

V1.04

Updated various sections for changed PIC18 sample project microcontroller, C30 compiler support and real time clock support.

V1.05

New look and re-structured with new format to make it easier to be quickly up and running with the driver.

Added code examples to the ‘Fast Reading Of Bulk File Data’ and ‘Fast Writing Of Bulk File Data’ sections.

V1.06

NXP LPC2365 ARM sample project and ffs_change_file_size function added.