2022-09-10 04:05 AM
In STM32F103C8T6 , I am using timer1 channel 1 and channel2 for PWM generation using DMA.
TIM1_CH1 uses DMA1_Channel 2
and TIM1_CH2 uses DMA1_Channel 3.
NOW i am using
full transfer interrupt : HAL_TIM_PWM_PulseFinishedCallback
and half transfer interrupt : HAL_TIM_PWM_PulseFinishedHalfCpltCallback
Now I don't know if these interrupts are called by DMA Ch2 OR Ch3.
Is there a way to know , from which channel is it coming?
my code is:
void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
{
for(int i = 30 ; i < 60 ; i++){
int temp1 =1330 - sinebuffer[i-30];
if(temp1 >0 && temp1< 1333)sinebuffer[i] = temp1;}
}
2022-09-10 01:01 PM
Another HAL failure by design... :D
Apparently you have to look for a pointer to DMA structure at htim->hdma[TIM_DMA_ID_CC1] and compare it to the DMA_HandleTypeDef structure in your code.
2022-09-10 09:48 PM
Just found a method.
void HAL_TIM_PWM_PulseFinishedHalfCpltCallback(TIM_HandleTypeDef *htim){
if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1)
{----}
if(htim->Channel == HAL_TIM_ACTIVE_CHANNEL_2)
{----}
}
where channel 1 is Timer channel number ,Not DMA channel number.
Thank you .
2022-09-11 07:31 AM
Turns out internally they do the same thing anyway: