cancel
Showing results for 
Search instead for 
Did you mean: 

F303, nrf24l01 interfacing problems

arolsen
Associate II
Posted on October 29, 2014 at 14:19

I tried porting someone else's code here:  

https://github.com/LonelyWolf/stm32/blob/master/Nrf24l01/nRF24l01.c

to F3 (his is for the F1 family).

I'm using one of the 

http://www.addicore.com/2pcs-Addicore-nRF24L01-Wireless-Transceiver-p/112.htm

 and an stm32f3discovery board.

Here is my code, I tried to make it as minimal as possible to show you what problem I'm seeing: 

https://github.com/synic/nrf_test/blob/master/src/main.c

The problem I'm seeing is in the nrf24_check() function.  After txbuf is written, and nrf_read_buf is called to read it back, txbuf and rxbuf don't match.  Instead of getting 0xA8, 0xA8, 0xA8, 0xA8, 0xA8 back I get 0xA8, 0xA8, 0, 0, 0xA8.

I'm trying to check the work with salaea logic, but I'm not sure what I'm looking for, it looks ok to me:

0690X00000605BcQAI.png

I'm not sure I'm setting the prescaler/speed correctly.  I'm using the HSI+PLL at 48MHz. 

thanks!

#stm32f3 #spi
5 REPLIES 5
jjmz
Associate II
Posted on October 29, 2014 at 22:08

Edit : sorry it was my first post, and it wasn't working ok from my tablet...

My answer was : Why are you using SendData16 and ReceiveData16 in function write_read, since the nrf24l01 probqbly only expect to get bytes (not 16bit words).?

arolsen
Associate II
Posted on October 29, 2014 at 22:43

I think the response got lost in there?

arolsen
Associate II
Posted on October 30, 2014 at 14:36

Mostly because I was just following that other code.  It uses SPI_I2S_SendData and SPI_I2S_ReceiveData, the former accepting a 16bit integer, the latter returning a 16bit integer.

I've tried changing it to SPI_SendData8 and SPI_ReceiveData8, however, this line just hangs then:

while (SPI_I2S_GetFlagStatus(SPI_PORT, SPI_I2S_FLAG_RXNE) == RESET); // Wait to receive byte

It never returns.

jjmz
Associate II
Posted on October 30, 2014 at 17:06

Well, your logic analyser acquisition was showing 16 bit transfers.

Maybe you should also try to change the MISO GPIO configuration :

it should be an input pin, and I am not sure the

GPIO_PinAFConfi

g

call is changing what you previously configured with

PORT

.

GPIO_OType

=

GPIO_OType_PP

; and GPIO_Init

(...).

arolsen
Associate II
Posted on October 31, 2014 at 17:50

You were right about the 16bit transfers.  I fixed that portion with the following code, and now it works:

uint8_t nrf24_read_write(uint8_t data) {

    while((SPI1->SR & SPI_I2S_FLAG_TXE) == RESET);

    SPI_SendData8(SPI_PORT, data);

    while((SPI1->SR & SPI_I2S_FLAG_RXNE) == RESET);

    return SPI_ReceiveData8(SPI_PORT);

}