我用W25Q16的读写函数测试w25Q64怎么总是失败?需要改动什么吗?

2019-07-21 05:59发布

 w25q64的SPI引脚和w25x16一样,只不过把片选改了,求解惑啊 [mw_shl_code=c,true]#define SPI_FLASH_PageSize 256 #define SPI_FLASH_PerWritePageSize 256 /* Private define ------------------------------------------------------------*/ #define W25X_WriteEnable 0x06 #define W25X_WriteDisable 0x04 #define W25X_ReadStatusReg 0x05 #define W25X_WriteStatusReg 0x01 #define W25X_ReadData 0x03 #define W25X_FastReadData 0x0B #define W25X_FastReadDual 0x3B #define W25X_PageProgram 0x02 #define W25X_BlockErase 0xD8 #define W25X_SectorErase 0x20 #define W25X_ChipErase 0xC7 #define W25X_PowerDown 0xB9 #define W25X_ReleasePowerDown 0xAB #define W25X_DeviceID 0xAB #define W25X_ManufactDeviceID 0x90 #define W25X_JedecDeviceID 0x9F #define WIP_FlagMask 0x01 /* Write In Progress (WIP) flag */ #define Dummy_Byte 0xA5 u32 SPI_FLASH_ReadID(void) { u32 Temp = 0, Temp0 = 0, Temp1 = 0, Temp2 = 0; /*????SPI_FLASH??????????*/ SPI_FLASH_CS_LOW(); /* ×???????ID ?±?ò??·????ü??*/ SPI_FLASH_SendByte(W25X_JedecDeviceID); Temp0 = SPI_FLASH_SendByte(Dummy_Byte); Temp1 = SPI_FLASH_SendByte(Dummy_Byte); Temp2 = SPI_FLASH_SendByte(Dummy_Byte); /*????SPI_FLASH??????????*/ SPI_FLASH_CS_HIGH(); Temp = (Temp0 << 16) | (Temp1 << 8) | Temp2; return Temp; } void SPI_FLASH_Test(void) { __IO uint32_t FlashID = 0; __IO uint32_t DeviceID = 0; /*????SPI_Flash??ID*/ FlashID = SPI_FLASH_ReadID(); printf(" ??????ID?? 0x%X", FlashID); /* ??????????SPI_Flash??ID??·????· */ // if ((FlashID == W25X16_FLASH_ID)) { /* ????SPI FLASH???????? */ SPI_FLASH_SectorErase(FLASH_SectorToErase); printf(" ????SPI FLASH????????: %s", Tx_Buffer); /* ??Tx_Buffer??????SPI FLASH?? */ SPI_FLASH_BufferWrite(Tx_Buffer, FLASH_WriteAddress, BufferSize); /* ??SPI FLASH??????????*/ SPI_FLASH_BufferRead(Rx_Buffer, FLASH_ReadAddress, BufferSize); /* ?ì?é??????????????????????·????? */ TransferStatus1 = Buffercmp(Tx_Buffer, Rx_Buffer, BufferSize); if(PASSED == TransferStatus1) { printf(" ??????????????????????! "); } else { printf(" ?í?ó-->????????????????????????! "); } /* ????SPI FLASH???????? */ SPI_FLASH_SectorErase(FLASH_SectorToErase); /* ??SPI FLASH??????????*/ SPI_FLASH_BufferRead(Rx_Buffer, FLASH_ReadAddress, BufferSize); /* ?ì?é??????????????·????· */ for (Index = 0; Index < BufferSize; Index++) { if (Rx_Buffer[Index] != 0xFF) { TransferStatus2 = FAILED; } } if(PASSED == TransferStatus2) { printf(" ?????ó??????????0xFF?????·! "); } else { printf(" ?í?ó-->?????ó????????????0xFF! "); } if((PASSED == TransferStatus1) && (PASSED == TransferStatus2)) { printf(" W25x16???????é????! "); } else { printf(" W25x16???????é?§°?! "); } } // else // { // printf(" W25x16???????é?§°?! "); // } /*SPI FLASH????????????*/ SPI_Flash_PowerDown(); }[/mw_shl_code] 我的板子上是w25q16芯片,w25Q64的外围电路是照着这个弄得,应该合适的吧 怎么连ID都读不出来……板子上的芯片用惯了,实际用个芯片感觉好难!
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
21条回答
横成岭侧成峰
1楼-- · 2019-07-23 09:10
我是用原子哥的程序一个字都没动。
但是mcu换成了F103VET6(100脚的),flash换成了W25Q64,一直读不到ID
横成岭侧成峰
2楼-- · 2019-07-23 13:32
 精彩回答 2  元偷偷看……
xzh5508
3楼-- · 2019-07-23 18:40
MARK,先谢谢了!

一周热门 更多>