Hi Mark,
I have a procedure that sends 264 bytes at time (and a small header), which is saved within the eeprom (spi) for updating the firmware. Everytime a block of data is read in to the processor (at the moment by serial), it is saved to a page number (which is specified in header). The code is as follows:
void SavePage(int PageNo,unsigned char *data)
{
unsigned char test_buffer1[SPI_FLASH_PAGE_LENGTH],test_buffer2[SPI_FLASH_PAGE_LENGTH];
int Loop;
for(Loop=0;Loop<264;Loop++) //used for testing, will simply use passed block
test_buffer2[Loop]=data[Loop];
uMemset(test_buffer1, 0x42, SPI_FLASH_PAGE_LENGTH); //set block 1 to known state
WriteToPage(PageNumber,test_buffer2) ; //write to memory
ReadFromPage(PageNumber,test_buffer1); //read back into buffer 1
for(Loop=0;Loop<264;Loop++)
if(test_buffer2[Loop]!=test_buffer1[Loop])
{
//error here on second time called..
}
}
Now the 1st time the procedure is called (with page Number 0) works fine, the second time called is when the error appears.
The second time the function is called, test_buffer2 holds the below, and when read back into buffer1 , an extra 0 is read in at beginning.
test_buffer2 = 0,0,178,23
test_buffer1 = 0,0,0,178,23
Regards
Neil