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.

TMS320F28069F: What is wrong with my setup code for Tx interrupt of SPI slave?

Part Number: TMS320F28069F
Other Parts Discussed in Thread: MOTORWARE

Hi TI members,

I am developing SPI slave using interrupt with motorware

other MCU is SPI master and F28069F is SPI slave.

I could receive couple of data from MCU via RxISR, and I'd like to send data to MCU using TxISR.

However TxISR is never called in my code.

would you please take a look at my setup code ?  Is there any wrong setting in it ?

void setupSpiA(SPI_Handle spiHandle)
{
	// Initialize SPI FIFO registers
	SPI_enableChannels(spiHandle);
	SPI_enableTxFifoEnh(spiHandle);
	SPI_enableTxFifo(spiHandle);
	SPI_disableTxFifoInt(spiHandle);
	SPI_clearTxFifoInt(spiHandle);
	//add for enable Tx int
	SPI_setTxFifoIntLevel(spiHandle, SPI_FifoLevel_1_Word);
	SPI_enableTxFifoInt(spiHandle);

	SPI_enableRxFifo(spiHandle);
	SPI_clearRxFifoInt(spiHandle);
	SPI_disableRxFifoInt(spiHandle);
	SPI_setRxFifoIntLevel(spiHandle, SPI_FifoLevel_1_Word);

	SPI_setTxDelay(spiHandle, 0);

	// Initialize SPI
	SPI_reset(spiHandle);
	SPI_disableLoopBack(spiHandle);
	SPI_setClkPolarity(spiHandle, SPI_ClkPolarity_OutputRisingEdge_InputFallingEdge);
	SPI_setCharLength(spiHandle,SPI_CharLength_16_Bits);

	SPI_setClkPhase(spiHandle, SPI_ClkPhase_Delayed);
	SPI_setMode(spiHandle,SPI_Mode_Slave);
	SPI_disableOverRunInt(spiHandle);
	SPI_enableTx(spiHandle);
	SPI_disableInt(spiHandle);

	SPI_enable(spiHandle);

	SPI_setPriority(spiHandle, SPI_Priority_FreeRun);
	SPI_setSteInv(spiHandle, SPI_SteInv_ActiveLow);
	SPI_setTriWire(spiHandle, SPI_TriWire_NormalFourWire);	
}

interrupt void spiATxISR(void)
{
	HAL_Obj *obj = (HAL_Obj *)halHandle;

	//while(SPI_getTxFifoStatus(halHandle->spiAHandle) != SPI_FifoStatus_Empty);
	tx_flag = SPI_getTxFifoStatus(halHandle->spiAHandle);
	SPI_write(halHandle->spiAHandle, spiTxBuf[spiTxIdx]);
	spiTxIdx++;

	if(spiTxIdx == txLen)
	{
		spiTxIdx=0;
		txLen=0;
	}

	tx_cnt++;
	SPI_clearTxFifoInt(halHandle->spiAHandle);
	PIE_clearInt(obj->pieHandle,PIE_GroupNumber_6);
}

FYI, I have filled spiTxBuf[] with data to be sent, and length is set at txLen

As I have tested, tx_cnt is never increased, it means spiTxISR() is never called on running

please take a look at my code.

Thanks in advance

  • Have you enabled the interrupt in PIEIER and the CPU IER as well?

    Whitney

  • Thanks for your prompt feedback.

    As you've mentioned, I have enabled only Rx interrupt in PIEIER and CPU IER.

    TxISR worked, after I added following code, .

    void SPI_enableInterrupt(void)
    {
    	  SPI_enableRxFifoInt(halHandle->spiAHandle);
    	  SPI_enableTxFifoInt(halHandle->spiAHandle);
    	  SPI_enableInt(halHandle->spiAHandle);
    	  PIE_enableInt(halHandle->pieHandle, PIE_GroupNumber_6, PIE_InterruptSource_SPIARX);
    	  PIE_enableInt(halHandle->pieHandle, PIE_GroupNumber_6, PIE_InterruptSource_SPIATX);
    	  CPU_enableInt(halHandle->cpuHandle, CPU_IntNumber_6);
    }

    Thanks a lot !