SdRaw_ReadByte(dPosition As Dword), Byte
dPosition: The byte position to read (valid values: 0 to 4,294,967,295).
Result Byte: The byte read from the specified position dPosition.
This command reads a single byte from the SD card at the position specified by dPosition.
Bytes within the same 512-byte sector are read more quickly, as the entire sector is stored in a RAM buffer. Once a byte from a new sector is requested, the buffer is updated with the data from that sector.
Each sector on the SD card is 512 bytes, and the data read is placed in the global SectorBuffer[512] array, which is already declared in the library. There is no need to declare this array in your program, and it can be accessed if needed. However, note that this array is also used for SdRaw_WriteByte() commands. Modifying it manually may cause sector data to become unsynchronized, especially if the same sector is being read and written at the same time.
Example:
SdRaw_ReadByte(78254)
TftSetUp(0) 'Set Screen TftResetScreen(BLACK) 'Reset screen While SdRaw_Init() <> 1 : Wend 'Initialize card TftPrintSndString("Init OK",1,0,0,1,GREEN,BLACK,0) 'Confirm initialization If SD_ReadSector(6) = 1 Then 'Read Sector 6 TftPrintSndString("Read Sector 6 OK",1,0,1,1,GREEN,BLACK,0) 'Confirm Read Sector 6 Else TftPrintSndString("Read Sector 6 Fail",1,0,1,1,GREEN,BLACK,0) EndIf TftPrintSndString("Byte 6 = " + Str$(Hex SectorBuffer[6]),1,0,2,1,GREEN,BLACK,0) 'Display byte 6 from the sector buffer TftPrintSndString("Byte 442 = " + Str$(Hex SectorBuffer[442]),1,0,3,1,GREEN,BLACK,0) 'Display byte 442 from the sector buffer Clear SectorBuffer : SectorBuffer[9] = 0xFA : SectorBuffer[358] = 0xC0 'Clear sector buffer and load some values If SD_WriteSector(10) = 1 Then 'Write buffer to sector 10 TftPrintSndString("Write Sector 10 OK",1,0,4,1,GREEN,BLACK,0) 'Confirm write to sector 10 Else TftPrintSndString("Write Sector 10 Fail",1,0,4,1,GREEN,BLACK,0) EndIf If SdRaw_WriteByte(0xF1, 5642) = 1 Then 'Write byte 0xF1 to position 5642 TftPrintSndString("Write Byte 0xF1 to 5642 OK",1,0,5,1,GREEN,BLACK,0) 'Confirm write Byte 0xF1 to position 5642 Else TftPrintSndString("Write Byte 0xF1 to 5642 Fail",1,0,5,1,GREEN,BLACK,0) EndIf If SdRaw_WriteByte(0xF2, 6032) = 1 Then 'Write byte 0xF2 to position 6032 TftPrintSndString("Write Byte 0xF2 To 6032 OK",1,0,6,1,GREEN,BLACK,0) 'Confirm write Byte 0xF2 to position 6032 Else TftPrintSndString("Write Byte 0xF2 To 6032 Fail",1,0,6,1,GREEN,BLACK,0) EndIf TftPrintSndString("Read Byte 5129 = " + Str$(Hex SdRaw_ReadByte(5129)),1,0,7,1,GREEN,BLACK,0) 'Read and display byte 5129 TftPrintSndString("Read Byte 5478 = " + Str$(Hex SdRaw_ReadByte(5478)),1,0,8,1,GREEN,BLACK,0) 'Read and display byte 5478 TftPrintSndString("Read Byte 5642 = " + Str$(Hex SdRaw_ReadByte(5642)),1,0,9,1,GREEN,BLACK,0) 'Read and display byte 5642 TftPrintSndString("Read Byte 6032 = " + Str$(Hex SdRaw_ReadByte(6032)),1,0,10,1,GREEN,BLACK,0) 'Read and display byte 6032 |
|
Created with the Personal Edition of HelpNDoc: Elevate Your CHM Help Files with HelpNDoc's Advanced Customization Options