cancel
Showing results for 
Search instead for 
Did you mean: 

SPI - RXNE not updating in debugger mode

abinsoftwares
Associate II
Posted on February 27, 2016 at 20:04

Hi,

I am pasting a piece of code I used for SPI communication in STM32F4 Discovery board.The code is working, I have no doubts. I faced an issue while in debugger mode. I added a break point at line number //
while
(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
Here RXNE is not getting updated and system will not execute the remaining code. The code works as expected when not in debugger mode or if breakpoint is added after line Can someone please explain me the reason behind this behavior. I am using A to B connector to connect my Discovery and I am using Keil 4. Thanks Abin


uint8_t SPI_read(uint8_t address)

{

GPIO_ResetBits(GPIOE, GPIO_Pin_3); 

address = 0x80 | address; 
// 0b10 - reading and clearing status


while
(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); 

SPI_I2S_SendData(SPI1, address);

while
(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);

SPI_I2S_ReceiveData(SPI1);


while
(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET); 

SPI_I2S_SendData(SPI1, 0x00);

while
(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);


GPIO_SetBits(GPIOE, GPIO_Pin_3);


return
SPI_I2S_ReceiveData(SPI1);

}

#spi-stm32f4-discovery-board
2 REPLIES 2
Posted on February 28, 2016 at 00:25

Ok, the debugger doesn't have some magic access rights, in reading the DR to display it, it will clear the SR/RXNE, just as it would if you read it in your program. I would strongly recommend not using a Peripheral Viewer to watch activity, rather just for configuration.

If you want to ''debug'' SPI or USART functionality you might want to read the SR and display salient details via GPIO pins, SWV or USART

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
abinsoftwares
Associate II
Posted on February 28, 2016 at 09:15

Thanks again :)