AnsweredAssumed Answered

SPI interruption problem

Question asked by bandari.franck on Apr 4, 2014
Latest reply on Jun 18, 2014 by k.michael
Hi all,

I would like to know if anyone has a problem when enabling the Tx buffer empty interrupt. In fact, when i put SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, ENABLE);  , the code coming after can't be executed

switch (USBButton)
    {
      /* BUTTON_USER button pressed */
     case 0x01:    
          SendMode=0x01;
          ReceveMode=0x00;
          CmdTransmitted = 0x01;
     break;
     .
     .
     .
}

if (CmdTransmitted != 0x00)
{    
    /* Enable the Tx buffer empty interrupt */
   SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, ENABLE);    
            
    /* Transmission mode */
   if(SendMode==0x01)
    {    
    STM_EVAL_LEDOn(LED7);
   while(CmdStatus==0x00);
            
   while(Tx_Idx < DATA_SIZE);
   /* Waiting until TX FIFO is empty */
  while (SPI_GetTransmissionFIFOStatus(SPI1) != SPI_TransmissionFIFOStatus_Empty)
  {}
    
   /* Wait busy flag */
    while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET)
  {}
 }

/*------SPI handler --------*/

void SPI1_IRQHandler(void)
{
    
 /* SPI in Master Tramitter mode--------------------------------------- */
  if (SPI_I2S_GetITStatus(SPI1, SPI_I2S_IT_TXE) == SET)
  {

   if (CmdStatus == 0x00)
   {
      SPI_SendData8(SPI1, CmdTransmitted);
      CmdStatus = 0x01;
       Tx_Idx=0x00;
        STM_EVAL_LEDOn(LED5);
   }
   else
   {
        if(SendMode)
        {  
          SPI_SendData8(SPI1, CommandRegister_Tx[Tx_Idx++]);
          STM_EVAL_LEDOn(LED3);
          if (Tx_Idx == 4)
          {
                STM_EVAL_LEDOn(LED10);
               /* Disable the Tx buffer empty interrupt */
              SPI_I2S_ITConfig(SPI1, SPI_I2S_IT_TXE, DISABLE);
          }
     } 
  }
}     

This code is for the master. In the slave side, i can receive what the master sends but it doesn't enter to if(SendMode==0x01). Any suggestion.
I hope that it's clear enough to understand the issue.

Outcomes