2014-10-29 06:19 AM
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 thehttp://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: 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:I'm not sure I'm setting the prescaler/speed correctly. I'm using the HSI+PLL at 48MHz. thanks! #stm32f3 #spi2014-10-29 02:08 PM
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).?2014-10-29 02:43 PM
I think the response got lost in there?
2014-10-30 06:36 AM
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 byteIt never returns.2014-10-30 09:06 AM
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 theGPIO_PinAFConfi
g call is changing what you previously configured withPORT
.
GPIO_OType
=
GPIO_OType_PP
; and GPIO_Init
(...).2014-10-31 09:50 AM
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);}