cancel
Showing results for 
Search instead for 
Did you mean: 

TIM1 update does not request DMA

DP_42
Associate

Hello,

I'm trying to generate a custom PWM output signal with the F103V8TxLQFP100. I took inspiration from here: Custom Signal generation using PWM and DMA - STMicroelectronics Community

The basic code looks like this:

...
uint8_t
tempBuffer[10];
tempBuffer[0] = 80;
tempBuffer[1] = 70;
tempBuffer[2] = 60;
tempBuffer[3] = 50;
tempBuffer[4] = 40;
tempBuffer[5] = 30;
tempBuffer[6] = 40;
tempBuffer[7] = 50;
tempBuffer[8] = 60;
tempBuffer[9] = 0;

(void)htim1.Instance->DIER;
while (1)
{
HAL_Delay(500);
__HAL_TIM_SET_COUNTER(&htim1, 0);
HAL_TIM_PWM_Start_DMA(&htim1,TIM_CHANNEL_1,(uint32_t*)tempBuffer,10);
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
...

htim1.instance->ARR = 89;

I modified HAL_TIM_PWM_Start_DMA() to enable the TIM update DMA request:

__HAL_TIM_ENABLE_DMA(htim, TIM_DMA_UPDATE);

I did this because with the trigger on capture compare I got multiple capture compare events in one timer period, when the compare values are assending (30, 40, 50,60).

My problem now is: It does not work. The DMA never finsh (HAL_TIM_PWM_PulseFinishedCallback() never gets called when DMA request is on TIM_DMA_UPDATE only in TIM_DMA_CC1). The timer is working (interrupt on tim1 update does work).

I had the same problem on the F042G6Ux  (multiple compare events in one timer period). On that chip i could simply change the DMA request form capture compare to update and everything was fine.

 

1 REPLY 1

The DMA Channel triggered by Update may be different than that triggered by CC1, so it's not just about enable the DMA trigger from Update, but also about changing the respective DMA channel.

You would be better off not using Cube/HAL for this. Btw. Cube/HAL anticipates that you have CC preload enabled, that would prevent the multiple DMA triggers per timer period (although that's still not quite optimal either and can lead to unwanted effects at the boundary cases).

JW