Hi Mark.
At last at me began work SPI memory. But now I have collided with a following problem: at record in a file the first 5 bytes of the kept information are ignored and at file reading I receive '-1' in "uGetFileLength" function and no received bytes. If I to the initial address add 'FILE_HEADER' the information is read out, but with wrong long (more short, than have been requested).
This is my small code example:
MEMORY_RANGE_POINTER ucFile;
MAX_FILE_LENGTH byte_retrieved = 0;
MAX_FILE_LENGTH file_offset = 0;
MAX_FILE_SYSTEM_OFFSET FileLength = 0;
u32 lAddress = 0;
unsigned char ucBlockErase[] = {M95XXX_BLOCK_ERASE_4K,0,0,0};
static const unsigned char ucWriteEnable[] = {M95XXX_WRITE_ENABLE};
// test_buffer - array to be copied to test_buffer2
for(i = 0; i < PageLen; i++)
{
if(i >= FILE_HEADER - 1)
{
test_buffer
= i - FILE_HEADER;
}
}
uMemset(test_buffer2, 0x0, PageLen);
ucFile = uOpenFile("0File.txt"); // open the file to be displayed
lAddress = (u32)ucFile;
ucBlockErase[3] = (unsigned char)(lAddress);
ucBlockErase[2] = (unsigned char)((lAddress) >> ;
ucBlockErase[1] = (unsigned char)((lAddress) >> 16);
fnSendSPIMessage((unsigned char *)ucWriteEnable, sizeof(ucWriteEnable)); // prepare write
fnSendSPIMessage((unsigned char *)ucBlockErase, PageLen); // prepare write
// !!! for write file to EEPROM to file first 5 bytes are ignored for HEADER information
uFileWrite((unsigned char*)ucFile, test_buffer, PageLen); // save the received data to file. Existing files will automatically be deleted
if(uFileCloseMime((unsigned char*)ucFile,(unsigned char*)ucMimeType) != PageLen)
{
// error
return;
}
ucFile = uOpenFile("0File.txt"); // open the file to be displayed
FileLength = uGetFileLength(ucFile); // Get opened file length
do
{
byte_retrieved = uGetFileData(ucFile + FILE_HEADER, file_offset, test_buffer2, FileLength );
if(byte_retrieved == 0)
{
return; // error
}
file_offset += byte_retrieved;
}while(byte_retrieved < PageLen);
Where is my problem?
I have use with SP6.
Thanks. Evgeni.