Skip to content

Issue with STM32WLE5 and SubGhz library for raw LoRa #3029

Description

@0x0fe

My target is STM32WLE5CCU6, the STM32 core is very last version available.
My issue is that , i can communicate with the STM32WLE5 radio with the subghz reduced API (compared to the original subghz library of the HAL) i can run the register read example and get the correct value back, so communication with the STM32WLE5 radio is working fine however i cannot exchange any actual packets with a regular SX1262.

My test setup is as following:
a first board with SX1262 and an MCU
a second board with SX1262 and MCU
Both flashed with a ping pong firmware that automatically exchange packets back and forth at about 16 packets per second, and display the local and remote rssi and snr.
the third board which is based on STM32WLE5CCU6.
It runs the exact same firmware as the two other board, except the SPI/interrupts are handled by the subghz APIs.

Of course, all Lora parameters are identical between all boards.
So, when i power board 1 and 2, immediately they exchange packets at 16 packets per second, very good rssi and snr, zero crc errors, zero drops.
But, if i test board 1 with STM32WLE5 or board 2 with STM32WLE5, no packet is ever exchanged. That is, the control boards cannot even receive a frame, and the STM32WLE5 cannot receive a frame either, occasionally i get crc error interrupt, that is it.

So, to me it looks like a problem with the 32MHz clock. The hardware itself is perfectly fine, it has been tested with an HAL firmware, so it is something to do with the Arduino core.

My question is, and it is not precise in the sub ghz readme, are we supposed to manually configure / enable some clocks related to the radio, i guess using LL or HAL API, when we want to use the radio of the STM32WLE5 with this ARduino core and subghz API?
What could i be missing? (i do control the RF switches manually as it should be, and i double checked the TX-RX / GPIO mapping, it is correct).

For safety, i enabled HSE with direct register access, before subghz.SPI.begin()

RCC->CR |= RCC_CR_HSEON;
while (!(RCC->CR & RCC_CR_HSERDY)) {  }

It did not help anything.

This is a typical log of what i get

23:49:55.855 -> SYSCLK 48000000 Hz(MSI)
23:49:55.855 -> LSYNCRH (after reset) )= 0x14
23:49:55.899 -> LSYNCRH (after init) = 0x14
23:49:55.899 -> RCC->CR = 000300bb (HSEON=1 HSERDY=1)
23:49:55.899 -> SX1262 init OK
23:49:56.396 -> IRQ 200
23:49:56.396 -> No peer heard -> becoming MASTER, starting pings
23:49:56.437 -> IRQ 1
23:49:56.942 -> IRQ 200
23:49:56.988 -> IRQ 1
. . .
23:50:02.741 -> IRQ 200
23:50:02.782 -> IRQ 1
23:50:03.290 -> IRQ 200
23:50:03.336 -> IRQ 1
23:50:03.816 -> IRQ 200
23:50:03.863 -> IRQ 1
23:50:04.190 -> IRQ 4
23:50:04.236 -> IRQ 42
23:50:04.689 -> IRQ 200
23:50:04.721 -> IRQ 1
23:50:05.246 -> IRQ 200
// 0x0001 TX done
// 0x0004 PreambleDetected 
// 0x0042 RxDone (0x0002) + CrcErr (0x0040)
// 0x0200 Timeout

So, the TX done is normal, the radio sends packets periodically to initiate the ping pong, that is what it is supposed to do, PreambleDetected is also normal, however RxDone with CrcErr and Timeout is not normal.

My state machine, which is eactly the same on the two references baords working perfectly together

void lora_handler(){

  if (radio.irqFired) {
    radio.irqFired = 0;
    uint16_t irq = sx_getIrqStatus(&radio);
    if (irq) Serial.printf("IRQ %X\n", irq);
    sx_clearIrqStatus(&radio, irq);
    SubGhz.enableInterrupt();       // radio-side flag is cleared
    if (irq & SX_IRQ_RX_DONE) {
      if (!(irq & SX_IRQ_CRC_ERR)) {
        onRxDone();
      } else {
        if (role == ROLE_UNKNOWN) {
          sx1262_startReceive(&radio, sx1262_msToSteps(STARTUP_LISTEN_MS));
        } else if (role == ROLE_MASTER) {
          sx1262_startReceive(&radio, sx1262_msToSteps(RX_TIMEOUT_MASTER_MS));
        } else {
          sx1262_startReceive(&radio, SX1262_RX_CONTINUOUS);
        }
      }
    }
    else if (irq & SX_IRQ_TX_DONE) {
      onTxDone();
    } 
    else if (irq & SX_IRQ_TIMEOUT) {
      onTimeout();
    }
  }
}

I can post the whole radio init / function code later if needed, but it is unlikely the problem comes from this since the exact same code is used on the two reference board working with SX1262 and they are working as intended with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions