-
Notifications
You must be signed in to change notification settings - Fork 430
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
SX128X begin() SPI timeout when BUSY defined on certain platforms #716
Comments
I'm not sure I fully understand. Do you mean to say that the BUSY does go low after reset (as it should be held high during startup), but then goes high again indefinitely before |
That seems about right - it looks like BUSY stays high after "F" is falling interrupt, "R" is rising interrupt on the BUSY pin
Explained:
In the section A falling interrupt arrives just before the section
In that go-around, the |
Thank you for the explanation. Could you try moving the digitalWrite that's pulling NSS low after the BUSY waiting loop? It's currently before that loop which is a bit of a strange order. |
Ahaha, I did exactly that just a few minutes ago! That was able to get things to initialize, but |
Thank you for confirming this, I suspected the order of NSS/BUSY was weird (from an unrelated issue), this is likely a bug. Regarding readData, are you sure there is really something to read? You don't seem to be checking the length of received packet using |
Thanks! I'm 99.9% certain the transmit side is functional; the buffer I'm feeding to the transmit function has valid data in it. The transmitter and receiver are flashed with a version that has NSS after the busy check, but the readData call seems to not modify the buffer that's handed to it. Here's the actual code in-situ: https://github.com/MUSTARDTIGERFPV/ESP32-INAV-Radar/blob/master/src/lib/Radios/LoRa_SX128X.cpp Note that the crypto call is a no-op for debugging purposes right now, I'm sending the buffer as-is, which always has at least some non-null data on account of the CRC at the end. |
Hmm, that's notable: |
It's worth saying: very very similar code (see LoRa_SX127X.cpp) works flawlessly on the SX127X series of chips, it's only the SX1280 that's giving me trouble. |
I was not able to replicate the issue, until I noticed that you are using implicit header mode. A bit more digging revealed that this mode is not actually handled properly, and getPacketLength always returns 0. It should be fixed in the latest commit, thanks for reporting! |
Describe the bug
Using RadioLib on ESP8285/SX1280 (ExpressLRS Receiver Hardware),
SX128x::begin()
returns -705. Instrumenting RadioLib I can see that it's hitting an SPI timeout during thereset()
call's attempt to put the chip in standby. Adding an interrupt handler on the BUSY pin, I can see that the pin is toggling state but thatSPIwriteStream
andSPITransferStream
's delays waiting for the BUSY pin to toggle occur just after the pin changes state. It seems like there's a race condition in catching the transition using the current approach (a spin loop) on the ESP8266 platform.I've tried:
readData()
requires BUSY to function properly)begin()
(gets us further, but eventually something breaks down the line)To Reproduce
In-situ: https://github.com/MUSTARDTIGERFPV/ESP32-INAV-Radar/blob/master/src/lib/Radios/LoRa_SX128X.cpp
Minimal reproduction:
Expected behavior
SX1280 can initialize without an SPI timeout when the BUSY pin is used such that readData returns valid data.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional info (please complete):
The text was updated successfully, but these errors were encountered: