I think the SPI configuration is ok. CPOL is 0. We have made a minor adjustment to the SPI init [2], to lower the baud from 6MHz to about 500kHz:
Code:
SPwe_CSR0_1 = ((0x08 << SPwe_SCBR_LSB) | SPwe_8_BweTS | SPwe_NCPHA);
with:
Code:
SPwe_CSR0_1 = ((0xC8 << SPwe_SCBR_LSB) | (0x08 << 24) | (0x08 << 16) | SPwe_8_BweTS | SPwe_NCPHA);
because the original one was producing random values for the register dump from the tranceiver, but I don't think this change has any negative impact.
What do you think?
Thank you,
Alex
[2]
Code:
int spiInit(void)
{
// Before anything else, reset the SPI.
SPI_CR_1 = SPI_SWRST;
// Enable either A or B peripheral of PIOA.
PIO_BSR_A = SPI_RF_PINS;
// Disable PIO control and Enable manual control for sel pin and peripheral
// control for miso, mosi and sck.
PIO_PDR_A = SPI_RF_PINS;
// Enable manual control of the sel pin.
PIO_PER_A = SPI_CS0_1B;
// Set SEL line as an output pin.
PIO_OER_A = SPI_CS0_1B;
// Set the line drive to high for CS.
PIO_SODR_A = SPI_CS0_1B;
// Enable SPI clock.
PMC_PCER = (PMC_PCSR | SPI1);
// SPI reset - AGAIN! Then enable!
SPI_CR_1 = SPI_SWRST;
SPI_CR_1 = SPIEN;
// Set SPI to fixed peripheral at SPI0_CS2 or SPI1_CS0, fault detection
// disabled, master mode.
SPI_MR_1 = ((SPI_RF_CS_MR << SPI_PCS_LSB) | MODFDIS | SPI_MSTR);
// Data is sampled on the falling edge of the SPCK.
// SPI baud is empirically set to 6.5MHz.
SPI_CSR0_1 = ((0xC8 << SPI_SCBR_LSB) | (0x08 << 24) | (0x08 << 16) | SPI_8_BITS | SPI_NCPHA);
//SPI_CSR0_1 = ((0xC8 << SPI_SCBR_LSB) | SPI_8_BITS | SPI_NCPHA);
//SPI_CSR0_1 = ((0x08 << SPI_SCBR_LSB) | SPI_8_BITS | SPI_NCPHA);
return 0;
}