-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
startWrite does not toggle CE for long enough on STM32duino boards #1010
Comments
This is news to me.
This proposed runtime overhead should only be applied to the stm32duino platform. We don't want regressive runtime overhead for other platforms. #if !defined(F_CPU) || F_CPU > 20000000
delayMicroseconds(10);
#endif
#ifdef ARDUINO_ARCH_STM32
if (F_CPU > 20000000)
delayMicroseconds(10);
#endif STM32Cube supportThere is a rather stale WIP branch that aims to support the STM32Cube IDE (see also #872). Additional precautions might be needed to ensure any STM32 (not only on ARDUINO platform) is affected by the proposal. This would be a long If the STM32 HALs (used in STM32Cube) don't define Update: Given the findings above (see links), the |
I also found compiler errors (for Generic STM32F4 series) in the scanner.ino example about using --- a/examples/scanner/scanner.ino
+++ b/examples/scanner/scanner.ino
@@ -141,7 +141,7 @@ void loop(void) {
if (Serial.available()) {
int8_t c = Serial.parseInt();
if (c >= 0) {
- c = min(125, max(0, c)); // clamp channel to supported range
+ c = min((int8_t)125, c); // clamp channel to supported range
constCarrierMode = 1;
radio.stopListening();
delay(2);
@@ -199,7 +199,7 @@ void loop(void) {
// Print out channel measurements, clamped to a single hex digit
for (int i = 0; i < num_channels; ++i) {
if (values[i])
- Serial.print(min(0xf, values[i]), HEX);
+ Serial.print(min((uint8_t)0xf, values[i]), HEX);
else
Serial.print(F("-"));
} |
There are other instances where RF24 lib expects Lines 1999 to 2019 in 8aa7103
but users can adjust RF24::txDelay (after RF24::begin() and every time the data rate is changed) as needed.
The numerous uses of |
@arthurfprecht I pushed a proposal to a new branch named |
Hi Brendan, first thank you very much for the quick reply. Good that you found in detail how the clock configuration work. It is somewhat odd, because some other STM32F boards (like the F103C) have pre-set CPU clocks via #define. Reallly good findings related to the other parts of the code impacted by this assumption. I will try to test the library still today and I will report back. Edit: Tested the code from branch stm32-fixes. The startWrite method now works flawlessly, also the scanner works as intended. Thank you very much for fixing the issue 😄 |
resolves #1010 * compute `F_CPU` at runtime for STM32 in `startWrite()` * fix scanner examples `min()`/`max()` calls
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):
What is the RX code?
What is the TX code?
The text was updated successfully, but these errors were encountered: