Restart One Shot ADC + DMA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-16 2:37 PM
Hi,
I have an STM32H747IGT6 that I wish to:
- Continuously sample 4096 ADC samples
- Transfer each sample from the peripheral to memory using DMA
- Trigger an interrupt at the end of the conversions
- After the CPU operates on the stored data, restart the process at item (1)
The process works fine through (3) with the ADC configured as LL_ADC_REG_DMA_TRANSFER_LIMITED and the DMA configured with LL_DMA_MODE_NORMAL. However, I can't figure out how to restart the DMA / ADC. Can anyone offer guidance on how to restart a one shot DMA transfer to memory from an ADC?
The ADC conversions are triggered from a timer.
Thanks!
Solved! Go to Solution.
- Labels:
-
ADC
-
DMA
-
STM32H7 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-16 3:32 PM
Ok, the missing step is to start a new conversion on the ADC. For others, see below using LL API.
LL_DMA_ConfigAddresses(DMA1,
LL_DMA_STREAM_1,
LL_ADC_DMA_GetRegAddr(ADC2, LL_ADC_DMA_REG_REGULAR_DATA),
(uint32_t)&shared_mem[SHMEM_SAMPLE_0_INDEX],
LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
LL_DMA_SetDataLength(DMA1, LL_DMA_STREAM_1, SHMEM_NUM_SAMPLES);
LL_DMA_EnableStream(DMA1, LL_DMA_STREAM_1);
LL_ADC_REG_StartConversion(ADC2);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-16 2:55 PM
Set the memory address back to the beginning of the buffer.
Set the number of transfers.
(Re)start the stream.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-16 3:25 PM
Hi TDK,
I've tried those steps and I agree they seem sensible for the DMA end. However, it seems like the ADC is still stopped after the end of the transfer and no more DMA requests are being generated.
The reference manual shows the following with no mention of how to restart the ADc for a second one shot sequence.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-01-16 3:32 PM
Ok, the missing step is to start a new conversion on the ADC. For others, see below using LL API.
LL_DMA_ConfigAddresses(DMA1,
LL_DMA_STREAM_1,
LL_ADC_DMA_GetRegAddr(ADC2, LL_ADC_DMA_REG_REGULAR_DATA),
(uint32_t)&shared_mem[SHMEM_SAMPLE_0_INDEX],
LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
LL_DMA_SetDataLength(DMA1, LL_DMA_STREAM_1, SHMEM_NUM_SAMPLES);
LL_DMA_EnableStream(DMA1, LL_DMA_STREAM_1);
LL_ADC_REG_StartConversion(ADC2);
