2023-11-23 06:51 AM
Hi,
I am trying to setup GPDMA with ADC with multiple channels on the Nucleo-H563ZI. The DMA should fill a buffer of the length of number of channels in a circular fashion, such that one entry in the buffer array always contains data of the same ADC channel. Unfortunately, I ran into several issues where I would be happy to get some input.
1. How do I enable ADC requests? Is that only possible with the function HAL_ADC_Start_DMA? If I use this function, it fills only the first entry in my buffer and does not circle through it.
2. When implementing GPDMA, I am able to get a circular buffer filling to work by setting it up in linked list mode. I create a node for every "transaction", with both the source and destination fixed. The source is the same for all nodes and I define one entry of my destination array as a destination for each node. I have set it up like this because according to the documentation it seems like a request can only trigger the execution of a full node or the whole linked list and not individual "transactions" within a linked list node. However, this does not work in link step mode (LinkStepMode = DMA_LSM_1LINK_EXECUTION), only in run-to-completion mode. I would like to set it up such that the ADC conversion requests a DMA transfer of only one value.
Could you maybe give me some pointers as to what I am doing wrong?
Thanks and best regards,
Julia
2023-11-27 06:32 AM
Hello Julia @JuliaK,
Thank you for your question !
1/ "How do I enable ADC requests?"
2/ "Could you maybe give me some pointers as to what I am doing wrong?"
You can download the STM32CubeH5 here and see this example to inspire you (under the root STM32Cube_FW_H5_V1.1.0\Projects\NUCLEOH563ZI\Examples\
Best Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-12-01 01:19 AM
Dear Pierre,
Please find attached my main.c and linked_list.c files. I tried different combinations and have seen the example code. The ADC_SingleConversion_TriggerSW_DMA example only has one ADC channel, whereas I would like to automatically read several channels and write the results to a buffer in a way that buffer[0] has the data from channel 0, buffer[1] has the data from channel 1, etc.
When implementing my linked list, it at least executes the code when I set LinkStepMode=DMA_LSM_FULL_EXECUTION, but the buffer is then not filled correctly with the different ADC channel results. I would like to trigger the execution of one list linked item as soon as an ADC conversion is done in order to fill my buffer as described above (buffer[0] has data from channel 0, etc). This is why I am trying to get it to work with LinkStepMode=DMA_LSM_1LINK_EXECUTION, but no success.
Just to avoid any misunderstandings, my questions were all related to the same goal of getting a multi channel ADC to work with DMA. It does not really matter to me if I set it up with a linked-list or if I just set up the ADC and then use the HAL_ADC_Start_DMA() function.
Thank you for your help and kind regards,
Julia
2023-12-01 05:54 AM - edited 2023-12-01 05:56 AM
Hello @JuliaK,
I took a quick look and here are some remarks to investigate more precisely :
Best Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-12-04 04:06 AM
Hi Pierre,
Thanks for your answer. Unfortunately, that did not resolve my issues.
Kind regards,
Julia
2023-12-04 07:37 AM - edited 2023-12-04 07:38 AM
Hello @JuliaK,
I am sorry to hear that, here some support about this callback function :
/* GPDMA1 interrupt Init */
HAL_NVIC_SetPriority(GPDMA1_ChannelXX_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(GPDMA1_ChannelXX_IRQn);
/**
* @brief This function handles GPDMA1 Channel 10 global interrupt.
*/
void GPDMA1_ChannelXX_IRQHandler(void)
{
/* USER CODE BEGIN GPDMA1_ChannelXX_IRQn 0 */
/* USER CODE END GPDMA1_ChannelXX_IRQn 0 */
HAL_DMA_IRQHandler(&handle_GPDMA1_ChannelXX);
/* USER CODE BEGIN GPDMA1_ChannelXX_IRQn 1 */
/* USER CODE END GPDMA1_ChannelXX_IRQn 1 */
}
Best Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-12-05 04:10 AM
Dear Pierre,
Thank you, that helped. I also saw that quite a lot of the setup of the ADC_SingleConversion_TriggerSW_DMA example is done in the stm32h5xx_hal_msp.c file. I now have an implementation of a continuously converting ADC together with DMA, which writes the data to the buffer correctly. However, the CPU seems to get stuck in executing the transfer callback functions and is not executing anything else. Can I disable these callback functions? Or can I lower the acquisition frequency somewhere?
Thank you and kind regards,
Julia
2023-12-06 06:27 AM
Hello @JuliaK,
Your welcome, I am glad to hear that.
Here some additional support :
Best Regards,
Pierre
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.