Description
What radio module do you use?
nRF24l01 PA+LNA (GT24 module)
What driver board(s) do you use?
STM32F411CE (a.k.a Black Pill development board)
If using Linux, what OS are you using?
No response
If using Linux, what RF24 driver did you select?
None
Describe your problem
Environment
I am using Arduino-compatible IDE (Sloeber 4.4.3), STM32Duino for the board package, RF24 library latest version. nRF24l01 PA + LNA boards are on both ends. Both transmitter and receiver are STM32s, TX is STM32F411 and receiver is STM32F103.
Overview
The method startWrite does not toggle CE for long enough on STM32duino boards, causing it to malfunction (transmission mode is never reached, toggle is shorter than 10 us).
Details
The method startWrite can call delayMicroseconds(10) to ensure CE is toggled for long enough time based on the CPU frequency. The CPU frequency (F_CPU) is checked during compile time, but for STM32Duino boards, F_CPU is changed during runtime (upon board initialization). This causes no delayMicroseconds() to be called and a very short CE toggle to happen.
Proposed solution
Substituting the current delay part of startWrite method with the following code fixed the issue (making the F_CPU check happen during runtime):
#if !defined(F_CPU)
delayMicroseconds(10);
#endif
if (F_CPU > 20000000)
delayMicroseconds(10);
What is the RX code?
#include <RF24.h>
// ...
What is the TX code?
// The code for RX is same for TX.
// See above code for RX