AnsweredAssumed Answered

SHARC SPI Slave for 8 bits

Question asked by LyleJohnson on Jul 14, 2011
Latest reply on Aug 16, 2011 by LyleJohnson

Hello!

 

I'm using an ADSP-21479 DSP in a product where the SPI B port is used as a slave.  That is all working, but I find that I must send two (2) bytes to the SHARC in order for it to recoginze that a byte has been received.  It appears to toss the second byte, so if, for example, I wish to send:

 

0x55 0xAA to the SHARC, I must send

 

0x55 0x00 (at this point the SHARC SPI B peripheral reconizes that something has been received and it accepts the 0x55 and sends out the low byte of whatever was in its Tx buffer) and then send

 

0xAA 0x00 (at this point the 0xAA is accepted)

 

The SPI peripheral is initialized:

 

void InitSPIB(void)
{
    *pSPICTLB = 0;
    *pSPIDMACB = 0;
    *pSPIBAUDB = 8;
    *pSPIFLGB = 0;
    *pSPICTLB = RXFLSH | TXFLSH;
    *pSPICTLB = PACKEN | SPIEN | OPD | MSBF | ISSEN | WL8;
    *pTXSPIB = 0x5A;    // dummy value for initial testing
}

 

This should set word length to 8 bits.

 

There is a polling loop that waits for the SPI peripheral to indicate it has received something:

 

if (*pSPISTATB & RXS)
{
    command();
}

 

where command() is a function that gets the byte and processes it.

 

The begining onf the command() function is:

 

void command(void)

{

     commandval = *pRXSPIB & 0xFF;

     *pTXSPIB = (commandval ^ 0xFF); // echo inverted bits

     switch(commandval)

     {

 

etc.

 

This is all working just fine as long as I pad every byte with a dummy byte of any value.  If the dummy byte is not sent, then the desired byte is not received and the next byte will be treated as the pad byte -- and its content lost.

 

What am I missing here?

 

Thank you for reading this,

 

Lyle Johnson

Outcomes