Read from Flash SPI2
Hi,
unsigned long LDR[] = {#include "test.ldr"};
I write successfully the 0xAD28 into flash as follow:
void Write_flash(unsigned char Block_ID, unsigned long* flash_page_data_buff, unsigned long long data_count)
{
if(Block_ID > FLASH_BLOCK_COUNT-1) {
printf("\nERROR: Invalid Flash Block ID\n");
while(1) asm("nop;"); }
printf("\n\n============================================================\n");
printf("\nPogramming the Flash from Block %d:\n", Block_ID);
unsigned long PRGM_ADDR = Block_ID * FLASH_BLOCK_SIZE;
while(data_count >= FLASH_PAGE_SIZE)
{
Write_flash_page(PRGM_ADDR, flash_page_data_buff, FLASH_PAGE_SIZE);
data_count -= FLASH_PAGE_SIZE;
flash_page_data_buff += FLASH_PAGE_SIZE;
PRGM_ADDR += FLASH_PAGE_SIZE;
}
if(data_count != 0x00)
{
Write_flash_page(PRGM_ADDR, flash_page_data_buff, data_count);
flash_page_data_buff += data_count;
PRGM_ADDR += data_count;
}
printf("Flash Programming Completed\n ");
printf("\n============================================================\n\n");
}
but when I want to read from flash, I get only 0xFF, as follow:
void Compare_flash(unsigned char Block_ID, unsigned long* flash_page_data_buff, unsigned long long data_count)
{
unsigned char temp_rd_byte, result = 1;
unsigned long long RD_count;
if(Block_ID > FLASH_BLOCK_COUNT-1) {
printf("\nERROR: Invalid Flash Block ID\n");
while(1) asm("nop;"); }
unsigned int READ_ADDR = Block_ID * FLASH_BLOCK_SIZE;
printf("\n\n============================================================\n");
printf("\nVerifying the Flash contents from Block %d:\n", Block_ID);
Select_Slave(); // Select Flash
flash_byte_access(FLASH_RD_DAT); // send sector erase command (0x64KB)
flash_byte_access(READ_ADDR >> 16); // send block address
flash_byte_access(READ_ADDR >> 8);
flash_byte_access(READ_ADDR);
for(RD_count=0; RD_count<data_count; RD_count++)
{
// *flash_page_data_buff++ = (flash_byte_access(DUMMY_BYTE));
temp_rd_byte = (flash_byte_access(DUMMY_BYTE));
if(temp_rd_byte != *flash_page_data_buff++)
{
result = 0;
break;
}
}
Deselect_Slave(); // deselct_flash;
if(result)
printf("\nSUCCESS: DATA written and verified to flash\n");
else
printf("\nERROR: DATA writing or verification unsuccessful\n");
printf("\n============================================================\n\n");
}
Any idea?
it writes 0xFFFF00FF on pREG_SPI2_RFIFO, when flash_byte_access(FLASH_RD_DAT); in Compare() function will be called.
Hello,
Which processor are you using?
Regards,
Lalitha.S
I am using BF706, series with bf609
Hello ,
This issue is handled through private support. To avoid duplication of efforts, you can continue the discussions through private support and we will post the final resolution here.
Regards,
Lalitha.S
Please log in to reply.