cancel
Showing results for 
Search instead for 
Did you mean: 

Bare metal SPI implementation problem

NicRoberts
Associate III

Hi,

 

I'm trying to get a bare metal implementation of SPI working on a STM32WB55 Nucleo board.

The transmit appears to work but I cant get the receive function to work. I'm using a loop back by connecting MOSI & MISO with a jumper.

When in debug I can see my Tx buffer getting loaded with the appropriate value but it never appears in the Rx buffer. When I step through the Tx code runs through as expected, in the Rx code though it looks like the SPI_FLAG_RXNE never gets set i.e. nothing ever arrives.
Ultimately I'm trying to connect with 2 x ADXL362s over the SPI bus.

I have attached a zip of the CubeIDE.

Any help with debugging this or pointers to how I go about that would be most appreciated. I'm getting code blindness trying to find the problem. 

11 REPLIES 11

It sounds like you're reading DR in the debugger, which will clear the RXNE flag.

If you feel a post has answered your question, please click "Accept as Solution".

I've tried it without viewing DR in the debugger & I still get nothing in the rx buffer. The receive part of the function never enters receive block which is conditional on RXNE.

I just tried to do the same thing with MX & HAL (which I was avoiding as I'm trying to learn how stuff works) but that doesn't work either (my UART buadrate issue for my UART debug did get resolved though - a separate issue)