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.

CCS/TMS570LS3137: SPI slave mode support

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hello every body

I have configured SPI as slave. I must reply  the commands which come from master device. commands include read, write, ... . when the master device issues a read command, first I should analyse command and then respond it. the read command is shown in below figure. 

I don't know how to respond it immediately. I don't know if it is possible or not. could you please tell me what I should do?

thanks

  • suppose mster device want to read from address 0x0E. I expect that with the below code the Master device reads 0x01 but it is not correct.

    void spiEndNotification(spiBASE_t *spi)
    {
    /* enter user code between the USER CODE BEGIN and USER CODE END. */
    /* USER CODE BEGIN (33) */
    if (spiRXData[0] == 0x03) // read
    {
    spiSendAndGetData(spiREG4, &dataconfig1_t, 1U, spiTXData, spiRXData);
    }
    else if (spiRXData[0] == 0x0E)
    {
    spiSendAndGetData(spiREG4, &dataconfig1_t, 1U, spiTXData, spiRXData);
    }
    else
    {
    spiTXData[0] = 0x01;
    spiSendAndGetData(spiREG4, &dataconfig1_t, 1U, spiTXData, spiRXData);
    }

    /* USER CODE END */
    }

    the spiEndNotification function is called twice in spi4HighLevelInterrupt or spi4LowLevelInterrupt functions. when Receive Buffer is Full and .when Transmit Buffer is Empty. 

  • Hello,
    Since you need time to decode Instruction and Address I don't see a way to respect the diagram above. What device you are using for Master?

    Best regards,
    Miro
  • thanks for your response. there is a little time between them. I also increased it, but it didn't work. the master device is a beaglebone black.
  • Hello,
    What I meant is that during the time needed for decoding of instruction and address (this will be made by application software) the master device will continue to send data. If time needed for decoding is too much you will loose data.

    Best regards,
    Miro
  • Hi

    I completely understood what you mean. there is a delay between instruction and address i.e. clk signal remains low after instruction is received

    I have two problem. first I don't want to receive an interrupt for "Transmit Buffer Empty". I don't know why the spi4HighLevelInterrupt is written in this way. if I only want to receive data it will generate an Transmit Buffer Empty interrupt and will execute " g_spiPacket_t[3U].tx_length--;" and "g_spiPacket_t[3U].txdata_ptr++;" and will call spiEndNotification function. I think that I function is not safe because if I only want to receive data I may only call spiGetData function, therefor spi tx buffer is not set.

    my second problem is when I read the instruction byte I set tx data for spi with spiSendAndGetData , the data is not sent in next transaction, it is sent after two transaction. 

    thanks.

    I apologize for my bad English.

  • Hello,
    If you use spiGetData TXINTENA bit will not be set and no interrupt will be generated when TXINTFLG is set to 1.

    Best regards,
    MIro
  • Hello,

    Do you have some progress with this issue?

    Best regards,
    Miro

  • Hello

    I have commented the second call of spiEndNotification which is for "Transmit Buffer Empty Interrupt" in spi4HighLevelInterrupt function. I'm using SPI4. According to HALCoGen the second spiEndNotification must not be called because the TXINT is always disable.

    thanks.