I have kept my frame size as 8 bits per frame and am sending words out like so:
int register_configure(int address)
{
//int data[5];
int data;
unsigned int data1,data2,data3,data4;
int address1, address2, address3,address4;
address1 = address & 0x000000ff;
address2=address & 0x0000ff00;
address2 = address2>>8;
address3 = address & 0x00ff0000;
address3 = address3>>16;
address4 = address & 0xff000000;
address4 = address4>>24;
address4 = address4 & 0x000000ff;
SPI0_PUSHR = ((SPI_PUSHR_CTAS(0x00)) | //The CTAR0 is selected
(SPI_PUSHR_CONT_MASK) | //Chip select is continuous through transfers
SPI_PUSHR_TXDATA(address4))|
SPI_PUSHR_PCS(1) ; //Pushes the required data
while((SPI0_SR & SPI_SR_TCF_MASK)==0){}//wait till the transfer is complete
data1 = SPI0_POPR; // the latest data in the RX FIFO is transferred to data1
while((SPI0_SR & SPI_SR_TFFF_MASK)==0); //wait till the TX FIFO is not empty
while((SPI0_SR & SPI_SR_RFDF_MASK)==0); //wait till the RX FIFO is not empty
SPI0_SR |= SPI_SR_TFFF_MASK; // TX FIFO is not empty set
SPI0_SR |= SPI_SR_RFDF_MASK; //sets the RX FIFO is not empty flag
SPI0_SR |= SPI_SR_TCF_MASK; //Transfer is complete flag set
SPI0_PUSHR = (SPI_PUSHR_CTAS(0x00)) |
(SPI_PUSHR_CONT_MASK) |
SPI_PUSHR_TXDATA(address3)|
SPI_PUSHR_PCS(1); //CS is asserted
while((SPI0_SR & SPI_SR_TCF_MASK)==0){}//wait till the transfer is complete
while((SPI0_SR & SPI_SR_TFFF_MASK)==0); //wait till the TX FIFO is not empty
while((SPI0_SR & SPI_SR_RFDF_MASK)==0); //wait till the RX FIFO is not empty
data2 = SPI0_POPR; // the latest data in the RX FIFO is transferred to data1
SPI0_SR |= SPI_SR_TFFF_MASK; // TX FIFO is not empty set
SPI0_SR |= SPI_SR_RFDF_MASK; //sets the RX FIFO is not empty flag
SPI0_SR |= SPI_SR_RFOF_MASK;
SPI0_SR |= SPI_SR_TCF_MASK; //Transfer is complete flag set
SPI0_PUSHR = (SPI_PUSHR_CTAS(0x00)) |
(SPI_PUSHR_CONT_MASK) |
SPI_PUSHR_TXDATA(address2)|
SPI_PUSHR_PCS(1);
while((SPI0_SR & SPI_SR_TCF_MASK)==0){}//wait till the transfer is complete
while((SPI0_SR & SPI_SR_TFFF_MASK)==0); //wait till the TX FIFO is not empty
while((SPI0_SR & SPI_SR_RFDF_MASK)==0); //wait till the RX FIFO is not empty
data3 = SPI0_POPR; // the latest data in the RX FIFO is transferred to data1
SPI0_SR |= SPI_SR_TFFF_MASK; // TX FIFO is not empty set
SPI0_SR |= SPI_SR_RFDF_MASK; //sets the RX FIFO is not empty flag
SPI0_SR |= SPI_SR_RFOF_MASK;
SPI0_SR |= SPI_SR_TCF_MASK; //Transfer is complete flag set
SPI0_PUSHR = ((SPI_PUSHR_CTAS(0x00)) |
(SPI_PUSHR_CONT_MASK) |
SPI_PUSHR_TXDATA(address1)|
SPI_PUSHR_PCS(1));
while((SPI0_SR & SPI_SR_TCF_MASK)==0){}//wait till the transfer is complete
while((SPI0_SR & SPI_SR_TFFF_MASK)==0); //wait till the TX FIFO is not empty
while((SPI0_SR & SPI_SR_RFDF_MASK)==0); //wait till the RX FIFO is not empty
data4 = SPI0_POPR; // the latest data in the RX FIFO is transferred to data1
SPI0_SR |= SPI_SR_TFFF_MASK; // TX FIFO is not empty set
SPI0_SR |= SPI_SR_RFDF_MASK; //sets the RX FIFO is not empty flag
SPI0_SR |= SPI_SR_TCF_MASK; //Transfer is complete flag set
data = (((data1<<24) & 0xff000000)|((data2<<16)&0x00ff0000)|((data3<<8)&0x0000ff00)|(data4 & 0x000000ff));
return data;
}
i.e. I have pushed data byte by byte four times. Is this approach wrong?