cancel
Showing results for 
Search instead for 
Did you mean: 

hdma_tim1_ch1.XferCpltCallback = TransferCompleteCallback; IS NOT TRIGGERIING

thannara123
Senior

I am transfering data array from an array to PWM register of TIM1.

int16_t sin_table[20]= { 0, 39, 77, 113, 147, 177, 202, 223, 238,247, 250, 247, 238, 223, 202, 177, 147, 113, 77, 39};

HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)sin_table, 20);

And i am trying to blink in complete transfer callback fuction as follows .

void TransferCompleteCallback(DMA_HandleTypeDef *hdma) {
{  
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
 
}

 

I am getting PWM signal as expected . but trigger the  TransferCompleteCallback).

by using break poiint the DMA Inerupt Handler triggers but not trigger the callback i said . 

 

whats the wrong am with please help me .

i am attaching the full code here 

 

aNY BODY HELP ME 

 

 

5 REPLIES 5
thannara123
Senior

Any help ?

 

MM..1
Chief II

Seems you missunderstan HAL callbacks ... read examples in folder repository firmware for your MCU...

You mark all MCUs, this isnt very helpfull. For example F4 from stm32f4xx_hal_tim.c func HAL_TIM_PWM_Start_DMA

 

switch (Channel)
  {
    case TIM_CHANNEL_1:
    {
      /* Set the DMA compare callbacks */
      htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
      htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;

 

thannara123
Senior

Hi Thanks , I didnt find any examples related DMA transfer complete  function trigger based projects .

 

Hi may i need to register the following function to trigger the calla back function 

HAL_DMA_RegisterCallback(&hdma, HAL_DMA_XFER_CPLT_CB_ID, My_DMA_TransferCompleteCallback);

 

Or any other way to do this , is there tutorials or mannual for it ?

Simply HAL prepare weak for you and yu cant choice any func, but need overide.

/**
  * @brief  PWM Pulse finished callback in non-blocking mode
  * @PAram  htim TIM handle
  * @retval None
  */
__weak void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
{
  /* Prevent unused argument(s) compilation warning */
  UNUSED(htim);

  /* NOTE : This function should not be modified, when the callback is needed,
            the HAL_TIM_PWM_PulseFinishedCallback could be implemented in the user file
   */
}

then rename in your code void TransferCompleteCallback to HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)

thannara123
Senior

Hi

 HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)  is used for one complete cycle isnt it ?

or one ARR value .

I require ne complete array finished that array has a lot of array elements for example 360 elements 

HAL_TIM_PWM_PulseFinishedCallback will triger 360 it require extra logic .

can i directly implement DMA complete transfer call back ?