Topic : Problem when monitoring SPI registers with Rlink ?

Forum : ARM

Original Post
Post Information Post
October 7, 2010 - 10:46am
Guest

Hi,

I'm using Rlink with a STM32 @ 72Mhz and i have noticed a problem when monitoring its SPI registers.
The RX buffer becomes empty from "not empty" state during a breakpoint pause !
And sometimes before a "read data" instruction without breakpoint ! (particularly when using a loop to poll the status of an external SPI peripheral).

When i do this :


-- Polling loop start --

/* Loop while DR register in not empty */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);

/* Send byte through the SPI1 peripheral */
SPI_I2S_SendData(SPI1, 0xA5); // 0xc7 for dummy Byte


BREAKPOINT HERE

/* Loop while DR register is empty */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);

Flash_data = SPI_I2S_ReceiveData(SPI1);

-- Condition on Flash_data to stop polling loop --

The RXNE flag of SPI is "SET" at the Breakpoint and becomes "RESET" without clic on "run' mode !
Then the program is blocked in the second "while" because of the empty state of RX buffer.

Without the Breakpoint it works but not all the times (that's why i had set a Breakpoint here).
The RX buffer is sometimes emptied before the "Read data" instruction and the program is blocked at next ''while'' !!
If I put a wait loop instead of the breakpoint (like for(i=0;i<0x2fffff; i++); it doesn't work too ...

Without Rlink, using the printf instruction and Hyperterminal, the program works well with or without the loop.

Is there a problem with STM32 SPI when using Rlink ?
Is there a particular setup of Rlink ?

Rémy

Replies
Post Information Post
+1
0
-1
December 3, 2010 - 2:27pm
Guest

I seem to have the exact same problem. Some kind of information regarding this would be welcome

+1
0
-1
January 22, 2011 - 11:18am
Guest

Hi,

I had this problem too, but eventually stumbled across the cause largely by accident.

It seems to be caused simply by having the corresponding SPI register window open while debugging. IMPORTANT - this causes the problem both for single-stepping, AND when free-running the code in debug mode. The latter caused my application to hang from anywhere between 2-30 seconds or so once running (which is how I originally encountered the problem).

My guess is that this problem happens because RIDE7/Rlink reads and refreshes all of the registers/watches which you have set up for debugging, either after every single-step, or regularly in the background when free-running the code in debug mode. When RIDE7/Rlink reads the SPI_DR Data Register in order to display it, this clears the RXNE flag in the SPI_SR Status Register and causes the problem.

The solution is simply to close the SPI debug register window in RIDE7. Of course this makes it a bit trickier to debug, but you could have the window open for debugging some bits, and close it when wanting to test the overall operation.

Hope this helps.

Best wishes,
Bart