Using AN00160 as the foundation with SPI Library 3.0.2, run the default program @ 100khz in SPI_MODE_1 - works fine according to the attached Total Phase Beagle SPI bus analyzer (sampling rate @ 50 Mhz; 10 Mhz also reports the same data). See below.
Same test with SPI_MODE_0 - does NOT work correctly. We recall this observation back in 2014.
Can someone confirm that SPI_MODE_0 works correctly or is this a code or Beagle tool bug ?
Will test the same code run using a different SPI bus analyzer (Zeroplus) later this week to confirm the issue is not Beagle tool related. Welcome all comments.
SPI_MODE_1 code run from AN00160:
Code: Select all
/* This application function sends some traffic as SPI master using
* the synchronous interface. Since this is run in simulation
* there is no slave, so the incoming data (stored in the 'val'
* variable) will just be zero.
*/
void app(client spi_master_if spi)
{
uint8_t val;
printstrln("Sending SPI traffic");
delay_microseconds(30);
spi.begin_transaction(0, 100, SPI_MODE_1);
val = spi.transfer8(0x11);
val = spi.transfer8(0x22);
val = spi.transfer32(0x33445566);
val = spi.transfer8(0x77);
spi.end_transaction(100);
delay_microseconds(40);
spi.begin_transaction(0, 100, SPI_MODE_1);
val = spi.transfer8(0x22);
spi.end_transaction(100);
printstrln("Done.");
_exit(0);
}

SPI_MODE_0 code run from AN00160:
Code: Select all
/* This application function sends some traffic as SPI master using
* the synchronous interface. Since this is run in simulation
* there is no slave, so the incoming data (stored in the 'val'
* variable) will just be zero.
*/
void app(client spi_master_if spi)
{
uint8_t val;
printstrln("Sending SPI traffic");
delay_microseconds(30);
spi.begin_transaction(0, 100, SPI_MODE_0);
val = spi.transfer8(0x11);
val = spi.transfer8(0x22);
val = spi.transfer32(0x33445566);
val = spi.transfer8(0x77);
spi.end_transaction(100);
delay_microseconds(40);
spi.begin_transaction(0, 100, SPI_MODE_0);
val = spi.transfer8(0x22);
spi.end_transaction(100);
printstrln("Done.");
_exit(0);
}
