nopnop2002 / esp-idf-sx126x

SX1262/SX1268/LLCC68 Low Power Long Range Transceiver driver for esp-idf
MIT License
86 stars 17 forks source link

Facing Error: RA01S: SPI Transaction error:10 #2

Open testqaibs opened 2 years ago

testqaibs commented 2 years ago

I am using tried using ESP32-WROOM-32D and ESP32-C3-13 devices with LoRa1262 chipset. I am facing RA01S: SPI Transaction error:10. Please let me know if I am missing anything.

Following logs printed on COM port:

entry 0x40080694 I (26) boot: ESP-IDF v4.4-dirty 2nd stage bootloader I (26) boot: compile time 01:07:15 I (27) boot: chip revision: 1 I (30) boot_comm: chip revision: 1, min. bootloader chip revision: 0 I (37) boot.esp32: SPI Speed : 40MHz I (41) boot.esp32: SPI Mode : DIO I (46) boot.esp32: SPI Flash Size : 4MB I (50) boot: Enabling RNG early entropy source... I (56) boot: Partition Table: I (59) boot: ## Label Usage Type ST Offset Length I (67) boot: 0 nvs WiFi data 01 02 00009000 00006000 I (74) boot: 1 phy_init RF data 01 01 0000f000 00001000 I (82) boot: 2 factory factory app 00 00 00010000 00100000 I (89) boot: End of partition table I (93) boot_comm: chip revision: 1, min. application chip revision: 0 I (100) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0a394h ( 41876) map I (124) esp_image: segment 1: paddr=0001a3bc vaddr=3ffb0000 size=02494h ( 9364) load I (128) esp_image: segment 2: paddr=0001c858 vaddr=40080000 size=037c0h ( 14272) load I (136) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=196c0h (104128) map I (176) esp_image: segment 4: paddr=000396e8 vaddr=400837c0 size=09070h ( 36976) load I (192) esp_image: segment 5: paddr=00042760 vaddr=50000000 size=00010h ( 16) load I (198) boot: Loaded app from partition at offset 0x10000 I (198) boot: Disabling RNG early entropy source... I (212) cpu_start: Pro cpu up. I (212) cpu_start: Starting app cpu, entry point is 0x4008109c 0x4008109c: call_start_cpu1 at C:/Users/Pravin/esp/esp-idf/components/esp_system/port/cpu_start.c:156

I (0) cpu_start: App cpu up. I (226) cpu_start: Pro cpu start user code I (226) cpu_start: cpu freq: 160000000 I (226) cpu_start: Application information: I (230) cpu_start: Project name: lora I (235) cpu_start: App version: 1 I (240) cpu_start: Compile time: Apr 14 2022 01:06:41 I (246) cpu_start: ELF file SHA256: d7058e82e5363bb4... I (252) cpu_start: ESP-IDF: v4.4-dirty I (257) heap_init: Initializing. RAM available for dynamic allocation: I (264) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM I (270) heap_init: At 3FFB2DD8 len 0002D228 (180 KiB): DRAM I (276) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM I (283) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM I (289) heap_init: At 4008C830 len 000137D0 (77 KiB): IRAM I (297) spi_flash: detected chip: generic I (300) spi_flash: flash io: dio I (305) cpu_start: Starting scheduler on PRO CPU. I (0) cpu_start: Starting scheduler on APP CPU. I (315) main: Frequency is 433MHz I (315) RA01S: CONFIG_MISO_GPIO=12 I (325) RA01S: CONFIG_MOSI_GPIO=13 I (325) RA01S: CONFIG_SCLK_GPIO=15 I (335) RA01S: CONFIG_NSS_GPIO=14 I (335) RA01S: CONFIG_RST_GPIO=33 I (335) RA01S: CONFIG_BUSY_GPIO=17 I (345) RA01S: CONFIG_TXEN_GPIO=-1 I (345) RA01S: CONFIG_RXEN_GPIO=-1 I (355) gpio: GPIO[14]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (365) gpio: GPIO[33]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (375) gpio: GPIO[17]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0 I (375) RA01S: spi_bus_initialize=0 I (385) RA01S: spi_bus_add_device=0 I (1425) RA01S: Reset I (3425) RA01S: syncWord=0x1424 I (3425) RA01S: SX126x installed E (5425) RA01S: SPI Transaction error:10

nopnop2002 commented 2 years ago

If you enable this, you will get more information.

https://github.com/nopnop2002/esp-idf-sx126x/blob/main/basic/main/main.c#L123


I (3425) RA01S: syncWord=0x1424

SyncWord is the correct value.

The wiring seems to be correct.

The wire cable may be too long.

testqaibs commented 2 years ago

Thanks for the quick reply. I have enabled LoRaDebugPrint, now I am getting following logs:

I (375) RA01S: spi_bus_initialize=0 I (385) RA01S: spi_bus_add_device=0 I (1425) RA01S: Reset I (2425) RA01S: ReadRegister: REG=0x740 I (2425) RA01S: DataIn:14 I (2425) RA01S: DataIn:24 I (3425) RA01S: syncWord=0x1424 I (3425) RA01S: SX126x installed I (4425) RA01S: WriteCommand: CMD=0x80 I (4425) RA01S: 00 --> aa E (5425) RA01S: SPI Transaction error:10

nopnop2002 commented 2 years ago

I (315) main: Frequency is 433MHz

The frequency is different between RA-01S and RS-01SH.

This is my log

Perhaps your wire cable is too long

I (0) cpu_start: Starting scheduler on APP CPU.
I (332) main: Frequency is 433MHz
I (332) RA01S: CONFIG_MISO_GPIO=19
I (342) RA01S: CONFIG_MOSI_GPIO=23
I (342) RA01S: CONFIG_SCLK_GPIO=18
I (352) RA01S: CONFIG_NSS_GPIO=15
I (352) RA01S: CONFIG_RST_GPIO=16
I (352) RA01S: CONFIG_BUSY_GPIO=17
I (362) RA01S: CONFIG_TXEN_GPIO=-1
I (362) RA01S: CONFIG_RXEN_GPIO=-1
I (372) gpio: GPIO[15]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (382) gpio: GPIO[16]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (392) gpio: GPIO[17]| InputEn: 0| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (392) RA01S: spi_bus_initialize=0
I (402) RA01S: spi_bus_add_device=0
I (442) RA01S: Reset
I (442) RA01S: ReadRegister: REG=0x740
I (442) RA01S: DataIn:14
I (442) RA01S: DataIn:24
I (452) RA01S: syncWord=0x1424
I (452) RA01S: SX126x installed
I (452) RA01S: WriteCommand: CMD=0x80
I (462) RA01S: 00 --> a2
I (462) RA01S: WriteCommand: CMD=0x9d
I (472) RA01S: 01 --> a2
I (472) RA01S: tcxoVoltage=0.000000
I (472) RA01S: WriteCommand: CMD=0x89
I (482) RA01S: 7f --> a2
I (482) RA01S: useRegulatorLDO=0
I (482) RA01S: WriteCommand: CMD=0x96
I (492) RA01S: 01 --> a2
I (492) RA01S: WriteCommand: CMD=0x8f
I (502) RA01S: 00 --> a2
I (502) RA01S: 00 --> a2
I (502) RA01S: WriteCommand: CMD=0x95
I (512) RA01S: 04 --> a2
I (512) RA01S: 07 --> a2
I (512) RA01S: 00 --> a2
I (522) RA01S: 01 --> a2
I (522) RA01S: WriteRegister: REG=0x8e7
I (522) RA01S: 18 --> a2
I (532) RA01S: WriteCommand: CMD=0x8e
I (532) RA01S: 16 --> a2
I (532) RA01S: 04 --> a2
I (542) RA01S: WriteCommand: CMD=0x98
I (542) RA01S: 6b --> a2
I (552) RA01S: 6f --> a2
I (552) RA01S: WriteCommand: CMD=0x86
I (552) RA01S: 1b --> a2
I (562) RA01S: 10 --> a2
I (562) RA01S: 00 --> a2
I (562) RA01S: 00 --> a2
I (572) MAIN: LoRaBegin=0
I (572) RA01S: WriteCommand: CMD=0x9f
I (572) RA01S: 00 --> a2
I (582) RA01S: WriteCommand: CMD=0xa0
I (582) RA01S: 00 --> a2
I (582) RA01S: WriteCommand: CMD=0x8a
I (592) RA01S: 01 --> a2
I (592) RA01S: WriteCommand: CMD=0x8b
I (602) RA01S: 07 --> a2
I (602) RA01S: 04 --> a2
I (602) RA01S: 01 --> a2
I (612) RA01S: 00 --> a2
I (612) RA01S: ReadRegister: REG=0x736
I (612) RA01S: DataIn:0d
I (622) RA01S: WriteRegister: REG=0x736
I (622) RA01S: 09 --> a2
I (622) RA01S: WriteCommand: CMD=0x8c
I (632) RA01S: 00 --> a2
I (632) RA01S: 08 --> a2
I (642) RA01S: 00 --> a2
I (642) RA01S: ff --> a2
I (642) RA01S: 01 --> a2
I (652) RA01S: 00 --> a2
I (652) RA01S: WriteCommand: CMD=0x08
I (652) RA01S: 03 --> a2
I (662) RA01S: ff --> a2
I (662) RA01S: 00 --> a2
I (662) RA01S: 00 --> a2
I (672) RA01S: 00 --> a2
I (672) RA01S: 00 --> a2
I (672) RA01S: 00 --> a2
I (682) RA01S: 00 --> a2
I (682) RA01S: ----- SetRx timeout=16777215
I (682) RA01S: WriteCommand: CMD=0x80
I (692) RA01S: 00 --> a2
I (692) RA01S: SetRxEnable:SX126x_TXEN=-1 SX126x_RXEN=-1
I (702) RA01S: WriteCommand: CMD=0x82
I (702) RA01S: ff --> a2
I (702) RA01S: ff --> a2
I (712) RA01S: ff --> a2
I (712) RA01S: ReadCommand: CMD=0xc0
I (712) RA01S: DataIn:52
I (722) RA01S: ReadCommand: CMD=0xc0
I (722) RA01S: DataIn:52
I (732) task_tx: Start
testqaibs commented 2 years ago

Thanks for giving your logs for comparison and timely replies. I am using LoRAa1262F30-915 chipset i.e from G-NiceRF. Hope this chipset is also supported with this code.

nopnop2002 commented 2 years ago

SX1262 has several options.

Using TCXO(Temperature-Compensated Crystal Oscillator)
SX1262/1268 can use the TCXO.
If the TCXO is used, the XTB pin is not connected.
However, the 6th pin (DIO3) of the SX1262/1268 can be used to power the TCXO.
Explanation for TXCO and antenna control is [here](https://github.com/beegee-tokyo/SX126x-Arduino).
Ra-01S / Ra-01SH does not use TCXO.

Power supply modes
SX1262/1268 has two power supply modes.
One is that only LDO used in all modes.
Another is that DC_DC+LDO used for STBY_XOSC,FS, RX and TX modes.
Explanation for LDO and DCDC selection is [here](https://github.com/beegee-tokyo/SX126x-Arduino).
Ra-01S / Ra-01SH use only LDO in all modes.

RF-Switching
In general, use DIO2 to switch the RF-Switch.
However, some tranceiver use an external gpio to switch the RF-Switch.
Ra-01S / Ra-01SH use the SC70-6 integrated load switch to switch between RFO and RFI.
Ra-01S / Ra-01SH use DIO2 to control this.
DIO2 = 1, CTRL = 0, RFC to RF1 Tx Mode.
DIO2 = 0, CTRL = 1, RFC to R21 Rx Mode.

You need to look at the schematic to set these options properly, but it's very esoteric. The default settings for this library are for Ra-01S / Ra-01SH. When using other than Ra-01S / Ra-01SH, you need to set them appropriately.

I am using LoRAa1262F30-915 chipset

Is the schematic published?

testqaibs commented 2 years ago

https://www.aliexpress.com/item/4000415800912.html

nopnop2002 commented 2 years ago

I want to see the schematic inside the LoRa1262F30 Without seeing this, the following cannot be judged.

Using TCXO(Temperature-Compensated Crystal Oscillator)
SX1262/1268 can use the TCXO.
If the TCXO is used, the XTB pin is not connected.
However, the 6th pin (DIO3) of the SX1262/1268 can be used to power the TCXO.
Explanation for TXCO and antenna control is [here](https://github.com/beegee-tokyo/SX126x-Arduino).
Ra-01S / Ra-01SH does not use TCXO.

Power supply modes
SX1262/1268 has two power supply modes.
One is that only LDO used in all modes.
Another is that DC_DC+LDO used for STBY_XOSC,FS, RX and TX modes.
Explanation for LDO and DCDC selection is [here](https://github.com/beegee-tokyo/SX126x-Arduino).
Ra-01S / Ra-01SH use only LDO in all modes.

RF-Switching
In general, use DIO2 to switch the RF-Switch.
However, some tranceiver use an external gpio to switch the RF-Switch.
Ra-01S / Ra-01SH use the SC70-6 integrated load switch to switch between RFO and RFI.
Ra-01S / Ra-01SH use DIO2 to control this.
DIO2 = 1, CTRL = 0, RFC to RF1 Tx Mode.
DIO2 = 0, CTRL = 1, RFC to R21 Rx Mode.
nopnop2002 commented 2 years ago

This is Ra-01S internal schematic.

If you look at this, you can see the following.

Ra-01S / Ra-01SH does not use TCXO. Ra-01S / Ra-01SH use only LDO in all modes. Ra-01S / Ra-01SH use the SC70-6 integrated load switch to switch between RFO and RFI. Ra-01S / Ra-01SH use DIO2 to control this.

Ra-01-internal

testqaibs commented 2 years ago

For schematics and additional references, can you please refer following link: https://www.nicerf.com/products/detail/sx1262-lora-module-lora1262f30.html

LoRa126XF30 2W High Power Wireless Transceiver Module V2.1.pdf

LoRa1262F30

nopnop2002 commented 2 years ago

I saw Product Spec.

If tcxoVoltage is set to a value other than 0, TCXO will be used, but I don't know what value is appropriate. The Product Spec does not mention this.

If useRegulatorLDO is set to true, DC_DC+LDO used for STBY_XOSC,FS, RX and TX modes. The Product Spec does not mention this.

    float tcxoVoltage = 0.0; // don't use TCXO
    bool useRegulatorLDO = false; // use only LDO in all modes
    int ret = LoRaBegin(frequencyInHz, txPowerInDbm, tcxoVoltage, useRegulatorLDO);

ProductSpec

mx-cyber commented 2 years ago

Do you have a solution to this problem?

nopnop2002 commented 2 years ago

No.

I don't know the proper value for tcxoVoltage.

If you know the appropriate value of tcxoVoltage of your Lora module, it will work.

    float tcxoVoltage = ???; // use TCXO
    bool useRegulatorLDO = true; // use TCXO
    int ret = LoRaBegin(frequencyInHz, txPowerInDbm, tcxoVoltage, useRegulatorLDO);
mx-cyber commented 2 years ago

OK, thank you very much for your reply