EmbDev.net

Forum: µC & Digital Electronics Strange SPI-Interrupt behaviour with STM32F107


Author: Marco (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi,

I am working on a spi-driver implementation for STM32F107. Things seem 
to work quite well, but I get sporadic interrupts on SPI with only the 
BSY-flag set. No other flags like TXE,RXNE, etc. are set.

Here is my interrupt handler for spi(it is called by SPI3_IRQHandler 
where I disable all interrupts temporaryly) When the sporadic interrupt 
occurs, spiLastEvent contains 0x80.
void generalSpiInterruptHandler(SPI_TypeDef* pSpix, Int32 spiNum) 
{
  UInt16 spiLastEvent = pSpix->SR & 0x83;

 if (spiLastEvent & SPI_I2S_FLAG_RXNE)
  {
    if ((NULL) != spiCallbacks[spiNum].rxCallback)
    {
      spiCallbacks[spiNum].rxCallback(spiNum);
    } 
  }
  else
  {
    if(spiLastEvent & SPI_I2S_FLAG_TXE)
    {
      if ((NULL) != spiCallbacks[spiNum].txCallback)
      {
        spiCallbacks[spiNum].txCallback(spiNum);
      }    
    }
    else
    {
      /* an error occoured */ 
      if (spiLastEvent & SPI_I2S_FLAG_OVR)
      {
        /* overrun error */
        if ((NULL) != spiCallbacks[spiNum].errorCallback)
        {
          spiCallbacks[spiNum].errorCallback(spiNum);
        }
      }
      else
      {
        if(spiLastEvent & SPI_FLAG_MODF)
        {
          /* Mode Fault */
          if ((NULL) != spiCallbacks[spiNum].errorCallback)
          {
            spiCallbacks[spiNum].errorCallback(spiNum);
          }
        }
        else
        {
          if(spiLastEvent & SPI_FLAG_CRCERR)
          {
            /* CRC error */
            if ((NULL) != spiCallbacks[spiNum].errorCallback)
            {
              spiCallbacks[spiNum].errorCallback(spiNum);
            }   
    
          }
          else
          {
            /* undefined error */
            if ((NULL) != spiCallbacks[spiNum].errorCallback)
            {
             spiCallbacks[spiNum].errorCallback(spiNum);
            }        
          }
        }
      }
    }
  }  
}

Anybody seen this behavious with sporadic BSY-interrupts as well?

Thanks a lot in advance!

--
Marco

Author: Angela (Guest)
Posted on:

Rate this post
0 useful
not useful
Hi Marco,

I hope u have solved the problem that u had.
Could u please provide me with the source code of the spi-driver for 
STM32F107.

Thxxx a lot.

Cheers,
Angela

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.