krzysztofgawrys / libmpsse

Automatically exported from code.google.com/p/libmpsse
0 stars 0 forks source link

SPI_ReadWrite returned unexpected result #56

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Linux Ubuntu (32-bit) 14.04LTS on VMware Win7 x64 host.
2. Single FT2232H Mini Module
3. Init the channel as,
    channelConf.ClockRate = 1000000;    // 1MHz
    channelConf.LatencyTimer = latency;
    channelConf.configOptions = SPI_CONFIG_OPTION_MODE0 | SPI_CONFIG_OPTION_CS_DBUS3 | SPI_CONFIG_OPTION_CS_ACTIVELOW;
    channelConf.Pin = 0x00000000;/*FinalVal-FinalDir-InitVal-InitDir (for dir 0=in, 1=out)*/
4. Use SPI_ReadWrite to do 4-byte transaction.

uint8_t LCD_RegRead(uint8_t addr) {
    uint32_t  sizeToTransfer = 0;
    uint32_t  sizeTransfered=0;
    FT_STATUS status;
    uint8_t inBuf[4], outBuf[4];

    sizeToTransfer=4;
    sizeTransfered=0;
    outBuf[0]=0x80;/* RS=1(cmd, status), RW=0(write) */
    outBuf[1]=addr;
    outBuf[2]=0x40;/* RS=0(data), RW=1(read) */
    outBuf[3]=0x00;
    inBuf[0] = 0x00;
    inBuf[1] = 0x00;
    inBuf[2] = 0x00;
    inBuf[3] = 0x00;
    status = SPI_ReadWrite(ftHandle, inBuf, outBuf, sizeToTransfer, &sizeTransfered,
        SPI_TRANSFER_OPTIONS_SIZE_IN_BYTES|
        SPI_TRANSFER_OPTIONS_CHIPSELECT_ENABLE|
        SPI_TRANSFER_OPTIONS_CHIPSELECT_DISABLE);
    APP_CHECK_STATUS(status);

    printf("inBuf=%02X%02X%02X%02X\n", inBuf[0], inBuf[1], inBuf[2], inBuf[3]);
    return inBuf[3];
}

What is the expected output? What do you see instead?

Scope capture shows consistent result on DI line but the inBuf readings are 
random each time and never returns the right value.

What version of the product are you using? On what operating system?

Shown in step 1 above.

Please provide any additional information below.

Tried different clock speed but makes no difference.

Original issue reported on code.google.com by danzhu_...@hotmail.com on 22 May 2015 at 4:54

GoogleCodeExporter commented 8 years ago
Sample results,

inBuf=FFFFFFFF
inBuf=32603260
inBuf=FFFFFFFF
inBuf=3260FFFF
inBuf=32603260

Also attached is the connection chart on FT2232H Mini module

Original comment by danzhu_...@hotmail.com on 22 May 2015 at 5:05

Attachments:

GoogleCodeExporter commented 8 years ago
Sorry I posted this issue at wrong place. It is the official libMPSSE-SPI 
library instead. Please feel free to close it.

Original comment by danzhu_...@hotmail.com on 22 May 2015 at 5:12