Having trouble with SPI setup on an 824. I'm obviously missing something, but can't see what. The issue is that the SCK line is idling high, and I need it idling low.
My init code is:
{code}
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);
Chip_SWM_MovablePinAssign(SWM_SPI0_MOSI_IO, NRF24L_MOSI_PIN);
Chip_SWM_MovablePinAssign(SWM_SPI0_MISO_IO, NRF24L_MISO_PIN);
Chip_SWM_MovablePinAssign(SWM_SPI0_SCK_IO, NRF24L_SCK_PIN);
Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);
// setup SPI support
Chip_SPI_Init(MIRF_SPI);
MIRF_SPI->CFG = (SPI_MODE_MASTER) | SPI_CFG_CPOL_LO | SPI_CFG_CPHA_FIRST;
MIRF_SPI->TXDATCTL = SPI_TXDATCTL_FLEN(7);
MIRF_SPI->TXCTRL = SPI_TXDATCTL_FLEN(7);
MIRF_SPI->DIV = 10; // clk = 24Mhz,
Chip_SPI_Enable(MIRF_SPI);
{code}
and a basic transfer function that looks like this:
{code}
uint8_t spiTransfer(uint8_t nData)
{
while (~MIRF_SPI->STAT & SPI_STAT_TXRDY);
MIRF_SPI->TXDAT = nData;
// Wait for RXRDY
while (~MIRF_SPI->STAT & SPI_STAT_RXRDY);
nData = MIRF_SPI->RXDAT;
return nData;
}
void Nrf24lTransferSync(uint8_t *dataout,uint8_t *datain,uint8_t len)
{
uint8_t i;
for(i = 0;i < len;i++)
{
datain[i] = spiTransfer(dataout[i]);
}
}
{code}
The init code sets CPOL_LO (although this should be the default anyway). Looking on a logic analyser I get this:

As you can see, clock is idle high, dropping low just before transmission starts. If I set CPOL_HI then it looks right on the analyser but now the samples are off. If I then set CPHA_SECOND to attempt to use the right edge (although that would then break the rx side) then the clock starts idling hi again (without changing the CPOL value).
I'm missing something - any pointers gratefully received!
Thanks
Simon