我用的芯片是stm32f051,用其spi串行读写ch374时,将数据0x34写入地址0x12中,然后读出地址0x12的数据时,读不出数据。ch374读写的代码如下:
void SPI_370_WRITE(uint8_t Waddr, uint8_t data)
{
SPI_370_CS_HIGH();
SPI_370_CS_LOW();
SPI_FLASH_SendByte(Waddr); //发送起始地址
SPI_FLASH_SendByte(0x80); //发送写命令
delay(10);
SPI_FLASH_SendByte(data);
SPI_370_CS_HIGH();
}
void SPI_370_READ(uint8_t Raddr)
{
SPI_370_CS_HIGH();
SPI_370_CS_LOW();
SPI_FLASH_SendByte(Raddr); //发送起始地址
SPI_FLASH_SendByte(0xC0); //发送读命令
delay(10);
ut(SPI_FLASH_SendByte(0xFF));
SPI_370_CS_HIGH();
}
用逻辑分析仪显示的波形如附件图:[img]file:///C:\Users\LXL\AppData\Roaming\Tencent\Users\865528138\QQ\WinTemp\RichOle\7%QYQ[62X7{QL_@3%`~X_YL.jpg[/img]
|