W25Q128JVSQ
可以讀讀取到ID,讀出0地址的16個字節全是0xFF。
然后寫0~16地址.寫完讀出來還是0xFF。用的原子的驅動程序和板子
以下是串口輸出:
Flash ID:0XEF17
JEDEC ID:0XEF4018
Status all:0X600200
SPI_FLASH data addr=0~16
//代碼如下
//SPI FLASH
SPI_Flash_Init();
print_hex("Flash ID:",SPI_Flash_ReadID());
print_hex("JEDEC ID:",flash_read_jedec_id());
print_hex("Status all:",flash_read_state_all());
for(temp=0;temp<16;temp++)
{
send.buf[temp]= temp;
}
flash_page_write(send.buf,0x0,0x0,16);
//flash驅動代碼
void flash_page_write(uint8 *pBuffer,uint16 page,uint8 addr,uint8 NumByteToWrite)
{
u8 i;
SPI_FLASH_Write_Enable(); //SET WEL
SPI_FLASH_CS=0; //使能器件
SPI1_ReadWriteByte(W25X_PageProgram); //發送寫頁命令
SPI1_ReadWriteByte(page>>8); //發送24bit地址
SPI1_ReadWriteByte(page);
SPI1_ReadWriteByte(addr);
for(i=0;i<NumByteToWrite;i++)SPI1_ReadWriteByte(pBuffer[ i]);//循環寫數
SPI_FLASH_CS=1; //取消片選
SPI1_ReadWriteByte(0xff); //延時8個時鐘
SPI_Flash_Wait_Busy(); //等待寫入結束
}
網上搜索代碼大多是這樣。特意在每個CS拉高后延時8個CLK。還是沒有效果。
|