我用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条回答
LIUYABO
1楼-- · 2019-07-22 01:43
回复【5楼】八度空间:
---------------------------------
谢谢了,我再试试看是不是硬件的问题
LIUYABO
2楼-- · 2019-07-22 04:18
回复【5楼】八度空间:
---------------------------------
电路我测了没问题啊,和上面图中一样的。但是程序烧进去就是读写失败,我直接改了个CS片选,其他引脚和板子上的w25Q16共用SPI1引脚,为什么就是不行呢,大神有没有高招啊,教教我
LIUYABO
3楼-- · 2019-07-22 05:17
回复【8楼】正点原子:
---------------------------------
其实我的意思是我外扩的W25Q64和板子上的w25Q16共用SPI1引脚,不过把CS改成了另一个引脚这样没问题吧
正点原子
4楼-- · 2019-07-22 09:27
 精彩回答 2  元偷偷看……
正点原子
5楼-- · 2019-07-22 10:40
回复【9楼】LIUYABO:
---------------------------------
可以
八度空间
6楼-- · 2019-07-22 14:55
回复【7楼】LIUYABO:
---------------------------------
只要片选不公用即可,其他无所谓,不要同时选中两个片选就行

一周热门 更多>