cancel
Showing results for 
Search instead for 
Did you mean: 

SPI TXEIE is not SET even after configured it

WM_IR
Senior

I have done some debugging on SPI interrupt problem. So, I have a function that SPI_SendDataIT which means SPI send data with interrupt. the interrupt will be triggered if TXE flag is SET. But we have to enable the TXEIE first.

But, what happen is, after my code execute at line of:

pSPIHandle->pSPIx->CR2 |= (1 << SPI_CR2_TXEIE);

the TXEIE is not even SET. and I already check the register bit number is already correct. Im using stm32f302r8. What causes this problem?

One more, In my program, before I do the TXEIE become SET, I enable the SPI clock peripheral first, the TXE become SET.

So meaning the TXE already SET before making the TXEIE become SET.

can someone help me on this issue? Here I attached the picture:

  1. TXE is SET after SPI peripheral clock is enabled

0693W00000BckgSQAR.png 

2.The TXEIE is not SET eventhough inside the program I already make it SET

0693W00000BckgIQAR.png

7 REPLIES 7
  1. TXEIE does not disable TXE; it disables the interrupt resulting from TXE being set.
  2. Don't you have an ISR which clears TXEIE?

JW

TDK
Guru

You're not setting TXEIE. To set TXEIE:

SPIx->CR2 |= SPI_CR2_TXEIE;

If you feel a post has answered your question, please click "Accept as Solution".

Indeed...

This did not work. do you have any examples on this type of code that I can refer to?

  1. Yes, I am aware of this point. Isnt that to get interrupt from TXE being SET only happen if we SET the TXEIE? my problem is my TXEIE is not SET.
  2. Yes, I have
If you can’t get the single line of code I posted to work, I don't think an example is going to help either.
If you feel a post has answered your question, please click "Accept as Solution".

uint8_t SPI_SendDataIT(SPI_Handle_t *pSPIHandle, uint8_t *pTxBuffer, uint32_t Len)

{

uint8_t state = pSPIHandle->TxState;

if(state != SPI_BUSY_IN_TX)

{

pSPIHandle->pTxBuffer = pTxBuffer;

pSPIHandle->TxLen = Len;

pSPIHandle->TxState = SPI_BUSY_IN_TX;

pSPIHandle->pSPIx->CR2 |= SPI_CR2_TXEIE;

}

return state;

}

Original code: pSPIHandle->pSPIx->CR2 |= (1 << SPI_CR2_TXEIE);

modified as your suggestion: pSPIHandle->pSPIx->CR2 |= SPI_CR2_TXEIE;

Is this correct?