STMicroelectronics / STM32CubeWL

STM32Cube MCU Full FW Package for the STM32WL series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on boards provided by ST (Nucleo boards)
Other
107 stars 54 forks source link

SUBGHZ HAL driver using SPI polling and not DMA... too slow #66

Open pieterconradie opened 1 year ago

pieterconradie commented 1 year ago

Hi there!

I have measured the SPI comms using a logic analyzer: SUBGHZ_SPI_timing

As you can see there is plenty room for improvement using DMA instead of polling. I'm referring to stm32wlxx_hal_subghz.c SUBGHZSPI_Transmit() and SUBGHZSPI_Receive(): https://github.com/STMicroelectronics/STM32CubeWL/blob/main/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_subghz.c#L1626-L1735

It would be better to formulate the SPI packet for transfer and then use DMA. This means that a HAL_SUBGHZ_ReadRegisters() would have to be rewritten: https://github.com/STMicroelectronics/STM32CubeWL/blob/main/Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_subghz.c#L863-L917

These unnecessary delays between each SPI byte will impact battery life. It is most notable when transmitting or receiving a large packet.

Best regards, Pieter https://piconomix.com

RJMSTM commented 1 year ago

hello @pieterconradie

Thank you for this report. We will get back to you as soon as we analyze it further. This may take some time. Thank you for your comprehension.

With regards, Rania

KRASTM commented 3 weeks ago

ST internal Reference: 190600

pieterconradie commented 3 weeks ago

Here is an example implementation for free :). For small SPI packets regular polling is used and for large SPI packets DMA is used.

stm32wlxx_hal_subghz.c.log