通过SPI(C232HM)读取EEPROM

问题描述 投票:0回答:1

我想使用 C232Hm MPSSE 电缆读取 M95128-DRMF4TG/K EEPROM,其中包含 C232H MPSSE 控制器。这是我的代码(C#):

private void ReadSPI(byte[] byteArray, int adress) //adress is 0x0100, bytearray has 998 Elements for 998 bytes to read
{
    byte msbAdress = (byte)(adress >> 8);
    byte lsbAdress = (byte)adress;
    // First send the adress needed to the EEPROM
    byte[] eepromSendData = new byte[] //Sending the EEPROM the command, that it shall return the data from the specific adress
    {
        0x10, 0x02, 0x00,
        0x03, msbAdress, lsbAdress
    };
    ftStatus = ftdiDevice.Write(eepromSendData, eepromSendData.Length, ref bytesWritten);

    
    byte msbLength = ((byte)(byteArray.Length >> 8));
    byte lsbLength = (byte)byteArray.Length;
    
    byte[] readCommand = new byte[] // readCommand for the C232H controller
    {
        0x20, lsbLength, msbLength
    };
    ftStatus = ftdiDevice.Write(readCommand, readCommand.Length, ref bytesWritten);
    ftStatus = ftdiDevice.Read(byteArray, (uint)byteArray.Length, ref bytesRead);

    if (ftStatus != FTDI.FT_STATUS.FT_OK || bytesRead != byteArray.Length)
    {
        MessageBox.Show("Error reading SPI");
        return;
    }
    bytesWritten = 0;
    bytesRead = 0;
}

我的 EEPROM 对于每个字节仅返回 0xFF。

写入readCommand是必要的,因为它会激活时钟。仅写入 ftdiDevice.Read 将导致程序冻结。

读取 EEPROM 的不同部分会得到相同的结果。 eepromSendData 数组命令 EEPROM 从该数组中的地址发送数据,按其应有的方式到达 EEPROM。 CS 已激活。可以测量时钟。 SOMI 引脚始终处于 2.4V(Vcc 为 3.3V),因此据我所知,EEPROM 根本不发送任何数据。

数据表 EEPROM

c# spi ftdi eeprom
1个回答
0
投票

发现问题了。我的同事给了我 EEPROM,告诉我它包含数据。但在寻找根本原因后发现,他给我的 EEPROM 中都不包含数据。抱歉浪费了大家的时间

© www.soinside.com 2019 - 2024. All rights reserved.