I am trying to modify the ReadSector subroutine in SDFilesystem.
I understand that standard read procedure of reading SD card will have to be done in sector of 512bytes. I am wondering if it is possible to read only, say 200 bytes rather than a full 512bytes. Will the SD card controller generate error if we attempt to do so? Let's say I modify it in this way:
Code: Select all
{
********************************************************************************
* Name : ReadSector (PRIVATE) *
* Purpose : Read a full sector from card to buffer. *
********************************************************************************
}
Sub ReadSector(pSector As LongWord, pBuffer As Boolean = True)
Dim TimeOut, Error As Byte
Dim Index As Word
#if SD_REINIT_SPI = TRUE
ReInitSPIPort()
#endif
....
....
Index = 0
If pBuffer Then
FSR0 = @Shared.CurrentSectorBuffer
Repeat // Read data block
#if SD_SPI = SW // Software SPI version - use SendByte
POSTINC0 = ReceiveByte()
#elseif SD_SPI = MSSP // MSSP version - use inline routine to optimise speed
SSPIF = 0
SSPBuffer = $FF
Repeat
ClrWDT
Until SSPIF = 1
POSTINC0 = SSPBuffer
#endif
Inc(Index)
Until Index = 200 // Instead of 512 bytes
Else
Repeat // Don't read data block
ReceiveByte()
Inc(Index)
Until Index = 200 // Instead of 512 bytes
Liak