cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with SPI Data Reception in Receive-Only Mode in STM32L4 with DMA for ADC Data Capture - DMA Synchronization

ajmw_
Associate III

I’m working on reading an ADC that’s interfaced with an STM32L4RET6, and I’m encountering an issue with data reception when switching SPI modes. Here’s the setup:

  • The ADC has a data rate of 8000 Hz, so I receive a DRDY (active low) signal every 125 µs.
  • DMA1 Channel 1 is configured as DMA_GENERATOR0 to handle the DRDY falling edge, which triggers a DMA request. This request sets the Chip Select (CS) low by writing to the GPIOX_BRR register and also generates an event.
  • DMA1 Channel 2 is assigned to SPI1_RX, synchronized with DMAMUX1 Channel 0  event (linked to DMA1 Channel 1) to trigger the SPI1 receive operation, capturing 6 bytes of ADC data.
  • SPI1 is configured in full-duplex mode in CubeMX, and once ADC configuration is complete, RX_ONLY mode is enabled to set SPI1 as a receive-only master, generating a continuous SPI clock.
  • On each DRDY falling edge, DMA1 Channel 1 triggers the Chip Select, and SPI1 then receives ADC data. In the SPI_RxCpltCallback(), I reset the RX_ONLY bit to stop the SCK and set the CS pin high again and In the EXTI_Callback() I set the RX_ONLY bit to start the SCK for next cycle.

The issue arises when switching from full-duplex to receive-only mode on the SPI: while the ADC configuration works in full-duplex, no data is received by the SPI after enabling RX_ONLY mode. Any ideas on why this might be happening or suggestions on how to troubleshoot this?

 

 

ajmw__0-1731320705187.pngajmw__1-1731320716960.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
ajmw_
Associate III

I resolved the issue by configuring SPI1 in full-duplex mode and synchronizing only SPI1_TX with DMAMUX CHANNEL0 Event. SPI1_RX was set to circular mode, allowing me to read all ADC channel data (27 bytes) every 125 µs (8 ksps) as per the setup below.

ajmw__2-1731907850012.png

 

ajmw__1-1731907832112.png

 

ajmw__0-1731907817911.png

 

View solution in original post

1 REPLY 1
ajmw_
Associate III

I resolved the issue by configuring SPI1 in full-duplex mode and synchronizing only SPI1_TX with DMAMUX CHANNEL0 Event. SPI1_RX was set to circular mode, allowing me to read all ADC channel data (27 bytes) every 125 µs (8 ksps) as per the setup below.

ajmw__2-1731907850012.png

 

ajmw__1-1731907832112.png

 

ajmw__0-1731907817911.png