您好,
我正在使用 SPI 接口与外部 RAM 内存 comunícate Ω 配合使用。 但是,时钟信号中漏掉了一些脉冲。 我附上一张图片:
我配置 了 WDEL =0和 CSHOLD =1以避免此问题,但问题仍然存在。
void writeFRAM(uint8 Ad2, uint8 Ad1, uint8 Ad0, uint8 dat)
{
spiDAT1_t dataconfig1_t;
dataconfig1_t.CS_HOLD = 1; // The chip select signal is deactivated at the end of a transfer after the T2CDELAY time has passed.
dataconfig1_t.WDEL = 0; // After a transaction, WDELAY of the corresponding data format will be loaded into the delay counter.
dataconfig1_t.DFSEL = SPI_FMT_0; // Data word format 0 is selected.
dataconfig1_t.CSNR = 0xFE; // Chip select (CS) number.
const uint16 WREN = 0x06; //WREN: Write enable command.
const uint16 WRITE = 0x02; //WRITE: Write command.
uint16 TX_Data_Master[5] = {WRITE, Ad2, Ad1, Ad0, dat}; //Set write command and direction in the output buffer.
spiTransmitData(spiREG3, &dataconfig1_t, 1, (uint16*)&WREN); //WREN command to enable writing operations.
spiTransmitData(spiREG3, &dataconfig1_t, 5, TX_Data_Master); //WREN command to enable writing operations.
}
uint8 readFRAM(uint8 Ad2, uint8 Ad1, uint8 Ad0)
{
spiDAT1_t dataconfig1_t;
dataconfig1_t.CS_HOLD = 1; // The chip select signal is deactivated at the end of a transfer after the T2CDELAY time has passed.
dataconfig1_t.WDEL = 0; // After a transaction, WDELAY of the corresponding data format will be loaded into the delay counter.
dataconfig1_t.DFSEL = SPI_FMT_0; // Data word format 0 is selected.
dataconfig1_t.CSNR = 0xFE; // Chip select (CS) number.
const uint16 READ = 0x03; //READ: Command to read an specific external memory location.
uint16 TX_Data_Master[4] = {READ, Ad2, Ad1, Ad0}; //Set read command and direction in the output buffer.
uint8 data = 0;
spiTransmitData(spiREG3, &dataconfig1_t, 4, TX_Data_Master); //WREN command to enable writing operations.
spiReceiveData(spiREG3, &dataconfig1_t, 1, (uint16 *) data);
return data;
}
谢谢大家,此致,
莱安德罗
