This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
您好,
我正在使用 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; }
谢谢大家,此致,
莱安德罗
你好, 莱安德罗,
我没有看到任何 SPI 时钟脉冲丢失。 两次传输之间的时钟间隔是预期的。
while (blocksize!= 0U)
{
IF ((SPI->FLG & 0x000000FFU)!=0U)
{
休息;
}
IF (块大小= 1U)
{
CHIP_Select_Hold = 0U;
}
/*SAFETYMCUSW 45 D MR:21.1 <批准>“有效的非空输入参数仅在此驱动程序中允许”*/
TX_Data =* srcsbu;
SPI->DAT1 =((UINT32)数据格式<<24U)|
((UINT32)芯片选择<< 16U)|
(沃莱)|
(CHIC_Select_Hold)|
(UINT32) Tx_Data;
/*SAFETYMCUSW 567 S MR:17.1,17.4 <批准>“需要指针增量”*/
srcbuf++;
/*SAFETYMCUSW 28 D MR:NA <批准>“Hardware status bit read check (硬件状态位读取检查)”*/
While (((SPI->FLG & 0x00000100U)!= 0x00000100U)
{
}/*等待*/
SpiBuf = SPI->BUF;
块大小--;
}
QJ 您好,
感谢你的回复。 我认为我的沟通混乱与这一差距有关。
我将检查从属设备为什么没有响应。
此致,
莱安德罗
你好, 莱安德罗,
请仔细检查内存设备所需的通信协议。 如有任何疑问,请告诉我们。 谢谢
QJ 您好,
非常感谢。 我认为这 解决 了这个问题。 但是,当我向从属设备发送命令时,在 响应过程中 CS 设置为高。 是否有办法 将 CS = 0V 从主变速 器保持在从属响应的末尾?
我附上 这种情况的记录。
黄色功能 应该是 从设备发出的信息,但 CS 设置为高(红色功能)。 我认为我可以使用 CS 引脚作为 Gio。
此致,
莱安德罗
我解决了! 我使用 SCS 引脚作为 GPIO,我可以从外部内存接收数据。
感谢您的问候!
莱安德罗