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 

 

 

12 REPLIES 12
BarryWhit
Lead II

You still have not understood what both MM and I have already explained to you. I'm sorry, but I just can't explain it any more clearly than I already have. 

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.
thannara123
Senior

Oh okay i got and corrected it as follows 

void PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
{ if (htim->hdma[TIM_DMA_ID_CC1] != NULL && htim->hdma[TIM_DMA_ID_CC1] == &hdma_tim1_ch1)
{
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
}
}

htim1.PWM_PulseFinishedCallback = PWM_PulseFinishedCallback;

 

I get Triggered as expected .

But I have two problems as follows

The DMA array size is 20 elements.

Total Transfer Time=506 Âµs×20=10.12 ms (as per pwm SIGNAL )

See the picture

k.png

why some red marked area is it continously  (blue is the transfer complete callbak led toggeling signal ) ?

Also see the picture below 

k1.png

Here the blue line is the DMA complete trigger there take an 8 usecon ow to reduce it from the pwm 

 

 

BarryWhit
Lead II

Please use the code highlight block for showing code, it's "</>"  on the posting toolbar. And ask new questions in a new thread, since  your issue has been solved.

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.