User manual

392
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
Mmc_Read_Sector
Mmc_Write_Sector
Prototype
sub function Mmc_Read_Sector(dim sector as longword, dim byref dbuff as
byte[512]) as word
Description The function reads one sector (512 bytes) from MMC card.
Parameters - sector: MMC/SD card sector to be read.
- dbuff: buffer of minimum 512 bytes in length for data storage.
Returns - 0 - if reading was successful
- 1 - if an error occurred
Requires MMC/SD card must be initialized. See Mmc_Init.
Example
‘ read sector 510 of the MMC/SD card
dim error as word
sectorNo as longword
dataBuffer as byte[512]
...
sectorNo = 510
error = Mmc_Read_Sector(sectorNo, dataBuffer)
Notes None.
Prototype
sub function Mmc_Write_Sector(dim sector as longword, dim byref data as
byte[512]) as word
Description The function writes 512 bytes of data to one MMC card sector.
Parameters - sector: MMC/SD card sector to be written to.
- dbuff: data to be written (buffer of minimum 512 bytes in length).
Returns - 0 - if writing was successful
- 1 - if there was an error in sending write command
- 2 - if there was an error in writing (data rejected)
Requires MMC/SD card must be initialized. See Mmc_Init.
Example
‘ write to sector 510 of the MMC/SD card
dim error as word
sectorNo as longword
dataBuffer as byte[512]
...
sectorNo = 510
error = Mmc_Write_Sector(sectorNo, dataBuffer)
Notes None.