I would like to look at a register level SPI example for the ADSP-SC573. I managed to get my code to work but I don't know if I do things the optimal way.
I'm trying to figure out how code the following sequence (not using DMA or interrupts for now):
- Setup SPI0
- Set chip select low
- Send a few 16-bit words
- Set chip select high
- Turn off SPI0.
This is my code for now:
// Setup SPI0 register settings
*pREG_SPI0_CTL = 0x0; // Keep SPI module off while setting up registers
*pREG_SPI0_SLVSEL = 0xFE20; // Set CS high
*pREG_SPI0_CLK = 0xA;
*pREG_SPI0_DLY = 0x301;
*pREG_SPI0_RWC = 0;
*pREG_SPI0_RWCR = 0;
*pREG_SPI0_RXCTL = 0;
*pREG_SPI0_TWC = 0;
*pREG_SPI0_TWCR = 0;
*pREG_SPI0_TXCTL = 0x5;
*pREG_SPI0_RXCTL = 0x5;
*pREG_SPI0_CTL = 0x203;
*pREG_SPI0_SLVSEL = 0xDE20; // Set CS low
*pREG_SPI0_TFIFO = 0xABDE; // Send data
// Wait until one word has been received
while ((*pREG_SPI0_STAT & BITM_SPI_STAT_RFS) == ENUM_SPI_STAT_RFIFO_EMPTY)
{
; // Wait
}
uint32_t rxData1 = *pREG_SPI0_RFIFO;
*pREG_SPI0_TFIFO = 0x123; // Send more data
// Wait until one word has been received
while ((*pREG_SPI0_STAT & BITM_SPI_STAT_RFS) == ENUM_SPI_STAT_RFIFO_EMPTY)
{
; // Wait
}
uint32_t rxData2 = *pREG_SPI0_RFIFO;
*pREG_SPI0_TFIFO = 0x4567; // Send more data
// Wait until one word has been received
while ((*pREG_SPI0_STAT & BITM_SPI_STAT_RFS) == ENUM_SPI_STAT_RFIFO_EMPTY)
{
; // Wait
}
uint32_t rxData3 = *pREG_SPI0_RFIFO;
*pREG_SPI0_SLVSEL = 0xFE20; // Set CS high
*pREG_SPI0_CTL = 0x0; // Disable SPI

Edit Notes
Pasted my new code (that works now).[edited by: masip at 2:24 PM (GMT -4) on 30 Aug 2022]