cancel
Showing results for 
Search instead for 
Did you mean: 

Timer triggered DMA based SPI communication using STM32WBA62CI

adnan-ashraf
Visitor

Hi,

I am working with the STM32WBA62CI MCU and need to communicate with an external SPI-based device by reading 34 registers (16-bit each) periodically. I want to store received data in RAM for 20 such events before overwriting it and continuing indefinitely.

Currently, I can successfully perform the DMA based SPI communication using HAL_SPI_TransmitReceive_DMA() triggered by a timer interrupt, incrementing the RX buffer manually by 34 on each transfer. However, I want to eliminate CPU involvement by triggering the SPI DMA transfers via peripheral interconnects and/or GPDMA triggers.

From my research, I understand there are two possible approaches:

  • SPI Autonomous Mode (trigger SPI):
    Configure SPI1 in autonomous mode triggered by LPTIM1_CH1.
    Start LPTIM1 so that its update event triggers SPI and automatically starts GPDMA channels 6 and 7 transfers as SPI requests them.
  • GPDMA Trigger Mode (trigger GPDMA):
    Configure SPI1 normally (no autonomous mode) and configure GPDMA channels 6 and 7 to be triggered by TIM3.
    Configure TIM3 in Output Compare mode with TRGO set to the update event and MSM disabled, then start TIM3.
    TIM3's update event should trigger GPDMA channels 6 and 7 to start SPI transfer.

Unfortunately, neither approach yields successful communication so far. Additionally, the .ioc file only allows triggering GPDMA channels from TIM3, TIM4, and COMP2, although the reference manual lists many more triggers including LPTIM1.

Could you please help me with the correct configuration details, including:

  1. GPDMA channel setup (fixed vs circular, normal vs linked-list mode) for TX buffer (34 halfwords fixed) and RX buffer (34 × 20 halfwords circular)
  2. Which timer to use and how to configure its TRGO settings in case of TIM3, whether to use Output Compare with "No Output" or "CH1", whether to enable Channel_1_Active for LPTIM1 and what to select from its drop-down menu, and what pulse value to set if the timer period is 10000
  3. Whether SPI should be configured in autonomous mode or regular mode
  4. Whether interrupts need to be enabled in this setup

Thank you for your assistance.

Best regards,

Adnan

0 REPLIES 0