Question
FATFs with w25qxx problem
Hey,
I have a problem with reading files larger than size of one sector of FATFs (4096 bytes).
Reading seems to be done correctly until it reaches 4096th byte of file, then data is corrupted. The problem appears when one part of readen data is on one sector and the second part is on another sector. It reads just one part of data correctly but not the second part.
DRESULT USER_read (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
BYTE *buff, /* Data buffer to store read data */
DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to read */
)
{
/* USER CODE BEGIN READ */
DRESULT res = RES_OK;
W25qxx_ReadSector(buff, sector, 0, 0);
return res;
/* USER CODE END READ */
}
/**
* @brief Writes Sector(s)
* @param pdrv: Physical drive number (0..)
* @param *buff: Data to be written
* @param sector: Sector address (LBA)
* @param count: Number of sectors to write (1..128)
* @retval DRESULT: Operation result
*/
#if _USE_WRITE == 1
DRESULT USER_write (
BYTE pdrv, /* Physical drive nmuber to identify the drive */
const BYTE *buff, /* Data to be written */
DWORD sector, /* Sector address in LBA */
UINT count /* Number of sectors to write */
)
{
/* USER CODE BEGIN WRITE */
/* USER CODE HERE */
W25qxx_EraseSector(sector);
W25qxx_WriteSector(buff, sector, 0, 0);
return RES_OK;
/* USER CODE END WRITE */
}
#endif /* _USE_WRITE == 1 */