This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SPI debugging proiblem ...

Hello,

I've got a problem of observing a SPI communication through real debugging on KEIL uVision debugger. I'm stepping line by line through the program debugging.

After flag SPI_SR_TXE (transmit register is empty => so we are ready to send a byte)is set (line 1), master SPI (STM32L4) send a byte (ex. 0x20) to the slave SPI (Gyro). Debugger shows up a received dummy byte from the slave (line 2 does that). That's OK.

Debugger waits at line 3. Flag RXNE (receiver register is not empty => so we are ready to read a byte) is set, so the conditions for while in this line is met. When I execute this (3rd) line flag clears and debugger cannot advances to line 4 ...

Also: Later on I commented lines 3 and 4 and got the same result (RXNE was cleared although I didn't read DR register; reading a register clears RXNE flag). Is there any underground reading from this regoster for debugging purposes ?

The snippet of this code is here:

while( (SPI2->SR & SPI_SR_TXE ) != SPI_SR_TXE ); )

*((volatile uint8_t*)&SPI2->DR) = dataToSend;

while((SPI2->SR & SPI_SR_RXNE ) != SPI_SR_RXNE);

receivedData = *((__IO uint8_t*)&SPI2->DR);

Thanks and best regards,
Ernest

Parents Reply Children