This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LS1224: Reading SPI5- conflicts

Part Number: TMS570LS1224


Hi,

I have a position sensor chip from Allergo. I want to read two parameters from the Chip. Parameters 1 is Absolute Angle. Parameter 2 is a error register. We need to fetch values every 66us (interrupt).

Reading Parameter 1:

"code 1

#define SPIDATA1 (*(volatile uint32 *)0xFFF7F43CU)
#define SPIFLAG (*(volatile uint32 *)0xFFF7F410U)
#define SPIBUF (*(volatile uint32 *)0xFFF7F440U)

SPIDATA1=0x070E2000;
while((SPIFLAG & 0x00000100U) != 0x00000100U)
{
}
AbsoluteAngleVal= SPIBUF & 0xFFFU;  If this alone is executed at 66us(interrupt), everything is working ok . The execution time is 2.6us.

"

Reading Parameter 2:

"code 2

#define SPIDATA1 (*(volatile uint32 *)0xFFF7F43CU)
#define SPIFLAG (*(volatile uint32 *)0xFFF7F410U)
#define SPIBUF (*(volatile uint32 *)0xFFF7F440U)

SPIDATA1=0x070E2400;
while((SPIFLAG & 0x00000100U) != 0x00000100U)
{
}
ErrRegister= SPIBUF & 0xFFFU; If this alone is executed at 66us(interrupt), everything is working ok . The execution time is 2.6us.

When I combine these two piece of codes and I try to read both parameters one after the other, I am not able to get the correct values in the buffer. Do I need to clear another registers before writing the next TxDATA?

  • Hi Sachin,

    1. The sensor may need more time to prepare the data. Can you increase the WDELAY and C2TDELAY, and try again?

    2. Before writing data to SPIDAT1, please make sure no error flag in SPIFLG register is set.

  • Hi QJ,

    I have observed that the output of the code 1 is the expected output from code 2 and vice versa. 

    Do you mean to increase the delay for both code 1 and code 2. code 1 is executed first and code 2 is executed after code 1. 

  • Hi Sachin,

    Can you please try the API from HAL code: spiReceiveData() ?

    spiDAT1_t dataconfig1_t;

    dataconfig1_t.CS_HOLD = FALSE;
    dataconfig1_t.WDEL = TRUE;
    dataconfig1_t.DFSEL = SPI_FMT_0;
    dataconfig1_t.CSNR = 0xFE;

    spiInit();

    /* Initiate SPI1 Transmit and Receive through Polling Mode*/
    spiTransmitAndReceiveData(spiREG1, &dataconfig1_t, 16, TX_Data_Master, RX_Data_Master);