I need help with SPI. I’m trying to talk with a TI AMC7834 chip. Its data sheet says, " Each serial-interface access cycle is exactly 24 bits long. A frame is initiated by asserting the CS pin low. The frame ends when the CS pin is deasserted high. The first bit transferred is the R/W bit. The next 7 bits are the register address (128 addressable registers), and the remaining 16 bits are data. For all writes, data is clocked in on the rising edge of SCLK. If the write access is not equal to 24 clocks, the data bits are not committed. On a read access, data is clocked out on the falling edge of the serial interface clock, SCLK, on the SDO pin."
I am setting up the SPI port alike so:
SPI.Configuration spiConfig = new SPI.Configuration(
ChipSelect_Port: Pins.GPIO_PIN_D4, // Chip select is digital IO 4.
ChipSelect_ActiveState: false, // Chip select is active low.
ChipSelect_SetupTime: 0, // Amount of time between selection and the clock starting
ChipSelect_HoldTime: 0, // Amount of time the device must be active after the data has been read.
Clock_Edge: true, // Sample on the rising edge.
Clock_IdleState: true, // Clock is idle when high.
Clock_RateKHz: 2000, // 2MHz clock speed.
SPI_mod: SPI_Devices.SPI1 // Use SPI1
spi = new SPI(spiConfig);
I think that every transaction must be 24 bits long. So, if I want to send just one 8-bit byte, I should actually send it as a UInt16 (The register byte plus two UInt16 bytes makes three).
The trouble is, it doesn’t work. When I do a simple Write/Read to a stable register like VendorID, I only get zeros.
Maybe it has something to do with the last sentence from the data sheet… falling edge for read? Can anyone offer a suggestion please?