Main Site Documentation

The use of SPI2 CHIPWORKX DEVELOPMENT SYSTEM


#1

The following program fragment:

private SPI.Configuration cmdConfig = new SPI.Configuration(ChipworkX.Pin.PA14, false, 0, 0, false,false, 20000, SPI.SPI_module.SPI2);
private readonly SPI spi; 

public void Readback(ReadAddressDecode rad)
        {
            cmdBuffer[0] = (byte)rad;
            cmdBuffer[1] = 0;
            cmdBuffer[2] = 0;
            spi.Write(cmdBuffer);
            cmdBuffer[0] = 0x1C;
            cmdBuffer[1] = 0xE0;
            cmdBuffer[2] = 0x00;
            spi.WriteRead(cmdBuffer, cmdBuffer, 3);
            for (int i = 0; i < 3; i++)
                Debug.Print("cmdBuffer[" + i + "]" + cmdBuffer[i]);
        }

CS low effective, my question is: whether the above code in the CS every 24 SCLK rising? Also send 3 bytes per 24 bit CS rising?


#2

CS goes “active” at the beginning then all SPI data is sent then CS pin goes “inactive”

But I think I see a problem in your code. To make things easier, use different buffers fro write and for read instead of using the same one and remove the offset.

//spi.WriteRead(cmdBuffer, cmdBuffer, 3);// no good
spi.WriteRead(cmdBufferTX, cmdBufferRX);

#3

Thank you for solving my problem. but as for this offset, do not quite understand, read or write buffer?