Question
SPI - RXNE not updating in debugger mode
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