2013-11-28 05:25 AM
Hey everybody,
I'm experiencing unexpected behaviour here:1. Debug point before entering GetFlagStatus(): SPI2-> SR = 32. while(SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET) {}3. Debug point in GetFlagStatus(): SPI2->SR = 2How can that be? No interrupts are called, as far as I can tell.Thanks in advanceEdit:I also triedwhile((SPI2->SR & SPI_I2S_FLAG_RXNE) == RESET) {}But even when a debug point is set at that very line, than SPI2->SR = 3, when I press F11 nothing happens, when I press F10 the debugger stays in the while loop with SPI2->SR somehow changed to 2. I dont get it...I also tried(SPI->SR = 2)SPI_I2S_SendData(SPI2, byte);(SPI->SR = 3)int i = 1;(SPI->SR = 2) #rxne #stm32 #spi #spi_i2s_flag_2013-11-28 05:47 AM
Clearing of the RXNE bit is performed by reading the SPI_DR register.
It's either a running DMA, or your debugger, which reads the SPI_DR register. JW2013-11-28 05:51 AM
I don't use DMA atm.
The reason was the debugger. If I don't open the peripheral display, everything works fine. Oh looord....Thank you so much, I'm working on this for 2 days now...2013-11-28 06:55 AM
Debuggers interfere with things. People overly assume they are non-invasive, but they are invasive, so things that can't be accessed transparently via scan chains in the background have to fiddled with by pushing in code and executing it. Peeking at peripheral register being particularly invasive, especially when doing so clears pending status. Generally if you want to validate/debug such routines, you need the system to be free standing, and get telemetry out a serial port. At the very least avoid parking peripheral or memory view windows in a way that makes your life difficult.