Hi Subhradeep Dutta,
1. SPI byte write and read, you can use this code:
uint8_t SPI_WriteReadData(uint8_t *pRead,uint8_t *pWrite,uint32_t uiLength)
{
uint16_t i;
for( i=0;i<uiLength;i++)
{
while(!(SPI0_S & SPI_S_SPTEF_MASK ) );
SPI0_D = pWrite[i];
while(!(SPI0_S & SPI_S_SPRF_MASK ) );
pRead[i] = SPI0_D;
}
return 1;
}
This is the polling mode, I have attached the code which wrote by myself for your reference.
2. SS pin as a manually controlled pin
As you know, if the SS is automatically controlled by the SPI module, the SS will go to high after each byte sending.
If you want to manually control, it is very easy, you just need to configure the SS pin as the GPIO, then when you want to send the data, pull low, after sending the data, pull high.
GPIO mux is ALT1, you can configure it in the PORTx_PCRn[MUX], then configure the GPIO, use GPIO to control it.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------