2023-03-21 12:45 AM
I am experimenting with the STM32WLE5 and the embedded SX126 LoRa-radio. (aka SubGHz)
I simply reset the SubGHz, then read its status, and this always returns a 'Failure To Execute Command' (according to section 13.5.1 GetStatus from SX126 datasheet) or when referring to the RM0461 reference manual, the GetStatus can be found in section 4.8.5 'Communication status information commands'
Here is the code :
SET_BIT(RCC->CSR, RCC_CSR_RFRST); // Activate Reset
HAL_Delay(10U);
CLEAR_BIT(RCC->CSR, RCC_CSR_RFRST); // Release Reset
HAL_Delay(250U);
uint8_t commandData[64] { 0 }; // contains parameters when sending a command to the SX126x
uint8_t responseData[64] { 0 }; // contains results when reading from SX126x
HAL_SUBGHZ_ExecGetCmd(&hsubghz, RADIO_GET_STATUS, responseData, 1);
uint8_t chipMode = (responseData[0] & 0x70) >> 4;
uint8_t commandStatus = (responseData[0] & 0x0E) >> 1;
theLog.snprintf("chipMode = [%02X], commandStatus = [%02X]\n", chipMode, commandStatus);
The response is :
chipMode = [02], commandStatus = [05]
and commandStatus = 05 means
0x5: Failure to execute command : The command was successfully processed, however the chip could not execute the command; for instance it was unable to enter the specified device mode or send the requested data
On the other hand, there does not seem to be any commandStatus value for 'OK'.
Please explain how to correctly interprete this status..
2023-03-21 01:52 AM
Some more feedback from testing : after setting the packetType, the commandStatus reads 0x01, which is not defined in the datasheet (ST) or RFU (Semtech)..
Getting the status of a peripheral is key to properly operating it, so I would like to understand 100% what is going on here.
2023-03-21 01:52 AM
You've reset the RADIO, perhaps there's a whole lot of dependencies there about it being setup and working for the operation to succeed? Or the context depends on the mode?
Mode = 2, STANDBY_RC
Similar
Data Sheet / Manual
https://www.mouser.com/datasheet/2/761/DS_SX1261-2_V1.1-1307803.pdf
2023-03-21 02:07 AM
Not sure there's going to be enough data to get to 100%
The Semtech core is running a state-machine or micro-code, which in all honesty is going to remain rather opaque.
It can't concurrently send and receive, and those states are reflected in the chip mode. Behaviours and register numbers and bit fields are different in LoRa and FSK modes.
The flow charts are often the best expression of the states and expectations about what needs to be done, and where statuses or bit flags have relevance.
2023-03-21 03:47 AM
Ok, that makes sense. Let me ask the question on the Semtech forum as well. Even if they don't reveal the internals of the SX126 (I've seen forum posts where they refuse to disclose certain internals..) I think something as essential as the chip's state should be well documented.
2023-03-21 03:53 AM
Yes, I reset the device, then let it wake up and ask for it's status.
This should be a simple thing.
The datasheet you refer to is outdated. I am using REV 2.1 (Dec 2021).
It's easy to find online.
Thanks for your help!
2023-03-21 04:33 AM
This is also reported on Semtech forum : [SX1262] Failure to execute command - Semtech Transceivers / SX126x family - FORUM
No simple answer I'm afraid...