EmbDev.net

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


von Marco (Guest)


Rate this post
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.
1
void generalSpiInterruptHandler(SPI_TypeDef* pSpix, Int32 spiNum) 
2
{
3
  UInt16 spiLastEvent = pSpix->SR & 0x83;
4
5
 if (spiLastEvent & SPI_I2S_FLAG_RXNE)
6
  {
7
    if ((NULL) != spiCallbacks[spiNum].rxCallback)
8
    {
9
      spiCallbacks[spiNum].rxCallback(spiNum);
10
    } 
11
  }
12
  else
13
  {
14
    if(spiLastEvent & SPI_I2S_FLAG_TXE)
15
    {
16
      if ((NULL) != spiCallbacks[spiNum].txCallback)
17
      {
18
        spiCallbacks[spiNum].txCallback(spiNum);
19
      }    
20
    }
21
    else
22
    {
23
      /* an error occoured */ 
24
      if (spiLastEvent & SPI_I2S_FLAG_OVR)
25
      {
26
        /* overrun error */
27
        if ((NULL) != spiCallbacks[spiNum].errorCallback)
28
        {
29
          spiCallbacks[spiNum].errorCallback(spiNum);
30
        }
31
      }
32
      else
33
      {
34
        if(spiLastEvent & SPI_FLAG_MODF)
35
        {
36
          /* Mode Fault */
37
          if ((NULL) != spiCallbacks[spiNum].errorCallback)
38
          {
39
            spiCallbacks[spiNum].errorCallback(spiNum);
40
          }
41
        }
42
        else
43
        {
44
          if(spiLastEvent & SPI_FLAG_CRCERR)
45
          {
46
            /* CRC error */
47
            if ((NULL) != spiCallbacks[spiNum].errorCallback)
48
            {
49
              spiCallbacks[spiNum].errorCallback(spiNum);
50
            }   
51
    
52
          }
53
          else
54
          {
55
            /* undefined error */
56
            if ((NULL) != spiCallbacks[spiNum].errorCallback)
57
            {
58
             spiCallbacks[spiNum].errorCallback(spiNum);
59
            }        
60
          }
61
        }
62
      }
63
    }
64
  }  
65
}

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

Thanks a lot in advance!

--
Marco

von Angela (Guest)


Rate this post
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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.