I'm working on MIBSPI Slave transfer test code.
MibSpi3 is Master and MibSpi5 is Slave and I have physically connected the CLK, CS, MOSI, MISO lines together on a TMS570LS31HDK.
I'm doing a transfer group of 16 of 16 bits.
The data transfer is working correctly except that the first 16 bit Master RX value is not what the SLAVE TX data value.
All the rest of the 16 data values are correct just the first 16 bit Master RX value is bad.
It looks like the least significant bit is not being read as when I send 0x2222 from the SLAVE, the MASTER reads 0x1111 (or 0x9111 if running at 10MHz) and when the SLAVE sends 0x1111, the MASTER receives 0x0888.
Below is my code and I've attached a .zip of my entire project.
What am I doing wrong such that the first bit sent seems to be getting lost??
Thanks,
-Joe
__________________________________
#define SPI_SLAVE mibspiREG5
#define SPI_MASTER mibspiREG3
uint16 slave_tx[16] = {0x2222, 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x8888, 0x9999, 0xAAAA, 0xBBBB, 0xCCCC, 0xDDDD, 0xEEEE, 0xFFFF};
uint16 slave_rx[16]= {0};
uint16 master_tx[16] = {0x0123, 0x0111, 0x0222, 0x0333, 0x0444, 0x0555, 0x0666, 0x0777, 0x0888, 0x0999, 0x0AAA, 0x0BBB, 0x0CCC, 0x0DDD, 0x0EEE, 0x0FFF};
uint16 master_rx[16] = {0};
mibspiInit();
while(1)
{
// Copy TX data from RAM to SPI buffers, for both slave and master
mibspiSetData(SPI_SLAVE, 0, slave_tx);
mibspiSetData(SPI_MASTER, 0, master_tx);
// Initiate the transfer
mibspiTransfer(SPI_SLAVE, 0); // will wait for CS/ to assert
mibspiTransfer(SPI_MASTER, 0); // Starts the transfer
while(!(mibspiIsTransferComplete(SPI_MASTER, 0)));
mibspiGetData(SPI_MASTER, 0, master_rx);
// Check to see if SLAVE is finished -- should be if MASTER is finished, check not needed?
while(!(mibspiIsTransferComplete(SPI_SLAVE, 0)));
mibspiGetData(SPI_SLAVE, 0, slave_rx);
}