cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with DCMI DMA callback registration. Environment: MCU: STM32MP157/M4; SW: STM32Cube FW_MP1 V1.6.0; Engineering Boot Mode

MLENG.1
Associate

Hi all!

Environment:

I use MX to configure the DCMI Peripheral including DMA!

MX generates MX_DMA_Init() and MX_DCMI_Init()

After DCMI initialization in main with the above mentioned functions I use the functions

HAL_DMA_RegisterCallback(&hdma_dcmi, HAL_DMA_XFER_CPLT_CB_ID, &DcmiDmaFullCplt) and HAL_DMA_RegisterCallback(&hdma_dcmi, HAL_DMA_XFER_HALFCPLT_CB_ID, &DcmiDmaHalfCplt) to register Halffull and Full DMA Callbacks.

Both callbacks are registered in the hdma_dcmi structure. Everthing ok so far.

Problem:

But when I execute

HAL_DCMI_Start_DMA(&hdcmi, DCMI_MODE_CONTINUOUS, (uint32_t) ae_dma_buffer, AE_DMA_BUFFER_SIZE); to start the peripheral, the function overwrites the dma full function pointer. Therefore the HAL callback is used and not my dma full callback function (half full works fine). Otherwise if I try to register the callbacks after calling HAL_DCMI_Start_DMA(), the registration is refused because the hdma-->state is different to HAL_DMA_STATE_READY.

So how sould I register the callbacks correctly now?

I wrote a work around to register the callback ("brutally" by hand) just after calling HAL_DCMI_Start_DMA() with the following instruction:

hdma_dcmi.XferCpltCallback = &DcmiDmaFullCplt;

This works fine but I think it doesn't fit smartly into the HAL concept!

So how shall I register full dma callbacks according to the HAL concept?

Thanks in advance.

Regards

Manfred

1 ACCEPTED SOLUTION

Accepted Solutions
STea
ST Employee

Hello @MLENG.1 ,

indeed, the HAL_DCMI_Start_DMA is overwriting your callback for the transfer complete in line 18:

HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)
{
  uint32_t circular_copy_length;

  /* Check capture parameter */
  assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode));

  /* Process Locked */
  __HAL_LOCK(hdcmi);

  /* Lock the DCMI peripheral state */
  hdcmi->State = HAL_DCMI_STATE_BUSY;

  /* Configure the DCMI Mode and enable the DCMI IP at the same time */
  MODIFY_REG(hdcmi->Instance->CR, (DCMI_CR_CM|DCMI_CR_ENABLE), (DCMI_Mode|DCMI_CR_ENABLE));

  /* Set the DMA conversion complete callback */this line is overwriting your callback 
  hdcmi->DMA_Handle->XferCpltCallback = DCMI_DMAXferCplt;

  /* Set the DMA error callback */
  hdcmi->DMA_Handle->XferErrorCallback = DCMI_DMAError;

  /* Set the dma abort callback */
  hdcmi->DMA_Handle->XferAbortCallback = NULL;

and since this is done only for the transfer complete callback, we don't see an issue with the Half transfer complete callback which remains as you set it.
this has been reported under ticket number 182936 (This is an internal tracking number and is not accessible or usable by customers).

BR

 

In order 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.

View solution in original post

3 REPLIES 3
AdamGordon
Associate

Hi Manfred,

I am wondering if you ever got a response to this issue or if you ever resolved it without resorting to manually editing the HAL driver?

I am having the exact same issue you described, but with using the LPUART peripheral and DMA. Manually editing the driver works for me as well, but I don't want to have to change any of their code.

Thanks,

Adam

STea
ST Employee

Hello @MLENG.1 and @AdamGordon ,


Sorry for the late response, I will start the investigation and try to reproduce this issue than I'll come back to you as soon as possible.

sorry for the inconvenience.
BR

In order 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.
STea
ST Employee

Hello @MLENG.1 ,

indeed, the HAL_DCMI_Start_DMA is overwriting your callback for the transfer complete in line 18:

HAL_StatusTypeDef HAL_DCMI_Start_DMA(DCMI_HandleTypeDef* hdcmi, uint32_t DCMI_Mode, uint32_t pData, uint32_t Length)
{
  uint32_t circular_copy_length;

  /* Check capture parameter */
  assert_param(IS_DCMI_CAPTURE_MODE(DCMI_Mode));

  /* Process Locked */
  __HAL_LOCK(hdcmi);

  /* Lock the DCMI peripheral state */
  hdcmi->State = HAL_DCMI_STATE_BUSY;

  /* Configure the DCMI Mode and enable the DCMI IP at the same time */
  MODIFY_REG(hdcmi->Instance->CR, (DCMI_CR_CM|DCMI_CR_ENABLE), (DCMI_Mode|DCMI_CR_ENABLE));

  /* Set the DMA conversion complete callback */this line is overwriting your callback 
  hdcmi->DMA_Handle->XferCpltCallback = DCMI_DMAXferCplt;

  /* Set the DMA error callback */
  hdcmi->DMA_Handle->XferErrorCallback = DCMI_DMAError;

  /* Set the dma abort callback */
  hdcmi->DMA_Handle->XferAbortCallback = NULL;

and since this is done only for the transfer complete callback, we don't see an issue with the Half transfer complete callback which remains as you set it.
this has been reported under ticket number 182936 (This is an internal tracking number and is not accessible or usable by customers).

BR

 

In order 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.