ΣSigmaStudio Ask AI Русский Log in

BF706 flash memory

Processors & DSP SVA Jan 31, 2020 00:00 1 replies Original on forum ↗
Thread Summary

Thread Summary

The user inquires about the functionality of two functions, `Write_flash_page` and `flash_byte_access`, for writing data to a W25Q32BV flash memory connected to a BF706. The final answer directs the user to continue the discussion through private support to avoid duplicating efforts, with the promise to post the resolution if appropriate. The functions handle the selection, write enable, and data transfer to the flash memory, with a status check to ensure the operation completes successfully.
AI Generated Content
Subscribe
SVA Question
Jan 31, 2020 00:00

Hi,

Can anyone explain to me what the following functions do?

void Write_flash_page(unsigned int PAGE_ADDR, unsigned char* flash_page_data_buff, unsigned short page_data_count)
{
*pREG_SPI2_SLVSEL &= ~ENUM_SPI_SLVSEL_SSEL1_HI ; // selct_flash;
flash_byte_access(FLASH_WR_EN); // send write enable command
*pREG_SPI2_SLVSEL |= ENUM_SPI_SLVSEL_SSEL1_HI ; // deselct_flash;
wait_for_flash_status(WEL, 1);

*pREG_SPI2_SLVSEL &= ~ENUM_SPI_SLVSEL_SSEL1_HI ; // selct_flash;
flash_byte_access(FLASH_PG_PRM); // send page program command
flash_byte_access(PAGE_ADDR >> 16);
flash_byte_access(PAGE_ADDR >> 8);
flash_byte_access(PAGE_ADDR);

int i;
for(i=0; i<page_data_count; i++)
flash_byte_access(*flash_page_data_buff++);

*pREG_SPI2_SLVSEL |= ENUM_SPI_SLVSEL_SSEL1_HI ; // deselct_flash;

wait_for_flash_status(WIP, 0);
}

unsigned char flash_byte_access(unsigned int Databyte)
{
// read RFIFO till it is empty
while(!(*pREG_SPI2_STAT & BITM_SPI_STAT_RFE))
*pREG_SPI2_RFIFO;

*pREG_SPI2_TWC = 1; // single byte instruction, no addr/data
*pREG_SPI2_TFIFO = Databyte; // command ID
while(!(*pREG_SPI2_STAT & BITM_SPI_STAT_TF)); // wait till completion
*pREG_SPI2_STAT = BITM_SPI_STAT_TF; // clear latch
return *pREG_SPI2_RFIFO;
}

let's assume, I have a buffer which I want to write it into the start addresse 0x0000 for flash (w25Q32BV) which it is in series with BF706. Then next buffer will be written into the next addresse 0xFF (size of each page is 256), and so on for the block number 0.

Best Regards

SVA

Anand Selvaraj Reply
Feb 14, 2020 00:00

Hi SVA,

This issue is already 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 if appropriate.

Regards,
Anand Selvaraj.