[SCB SPI] "Corrupted" SPI transfers
user_365962704 Aug 18, 2017 12:55 PMHi,
I'm still trying to finish a custom component for the nRF24 radios [1], i wanted to use the component on all the possible PSoCs, so i had to made it work with UDB and SCB blocks.
To test the component i did three projects (attached):
* using PSoC5LP (kit CY8CKIT-059) and SPI based on UDB blocks
* using PSoC4 (kit CY8CKIT-043) and SPI based on UDB blocks
* using PSoC4 (kit CY8CKIT-043) and SPI based on SCB blocks
So far i have no problems with the UDB projects (see nrf_udb image attached), but i'm having troubles with the SCB implementation (see nrf_scb attached image) the /SS line asserts between transfers.
I'm writing 2 bytes, the first byte contains the COMMAND + REGISTER and the second byte contains the DATA i want to write to the nRF REGISTER.
Here is the function i use to write to the nRF registers, on the top you can see the UDB version and below the SCB implementation:
void nRF24_WriteRegister(const NRF_REGISTER_t reg, const uint8_t data)
{
#if !defined(CY_SCB_SPI_H) // UDB Block
SPI_ClearRxBuffer();
SPI_ClearTxBuffer();
SS_Write(0);
SPI_WriteTxData(NRF_W_REGISTER_CMD | reg);
SPI_WriteTxData(data);
while(0 == (SPI_ReadTxStatus() & SPI_STS_SPI_IDLE));
SS_Write(1);
#else // SCB Block
SPI_SpiUartClearRxBuffer();
SPI_SpiUartClearTxBuffer();
SPI_SpiSetActiveSlaveSelect(0);
SPI_SpiUartWriteTxData(NRF_W_REGISTER_CMD | reg);
SPI_SpiUartWriteTxData(data);
while( SPI_SpiIsBusBusy() );
#endif
}
In the example projects both SPI peripherals have a 32 byte TX-FIFO, i'm not familiar enough with the SPI based on the PSoC4 SCB blocks so maybe i'm missing something very obvious, feel free to look into the code and let me know if i'm doing something silly :/ .
Thanks in advance
Carlos
PD: If you want to check the most up to date implementation you can find it here:
[1] github.com/C47D/nRF24_Component
-
nRF24.cywrk_.Archive01.zip 1.8 MB
-
nrf_scb.png 100.3 K
-
nrf_udb.png 77.4 K