cancel
Showing results for 
Search instead for 
Did you mean: 

Hello, I am working with a STM32F769 EVAL board and I want to make a 20kHz PWM using DMA. The issue I have is that I cannot start-up the timer for a GPIO. I do not find in the docs this information. Do you have an example made for this PWM on GPIO?

VMoca.1
Associate II
 
This discussion is locked. Please start a new topic to ask your question.
11 REPLIES 11

period and pulse are not initialized.

void PWM_Timer_Init(void)

{

   /* Enable TIM3 clock */

   __HAL_RCC_TIM3_CLK_ENABLE();

   /* Configuration for TIM3 */

   ConfTimer.Instance = TIM3;

   ConfTimer.Init.Prescaler = 215U;

   ConfTimer.Init.CounterMode = TIM_COUNTERMODE_UP;

   ConfTimer.Init.Period = 999U; //(1000000U / 1000U) - 1U;

   ConfTimer.Init.ClockDivision = 0U; /* no divider */

   ConfTimer.Init.RepetitionCounter = 0U;

   ConfTimer.Init.AutoReloadPreload = 0U; /* disabled */

   //ConfTimer.Channel = TIM_CHANNEL_2;

   if (HAL_TIM_PWM_Init(&ConfTimer) != HAL_OK)

   {

      Error_Handler();

   }

   sConfigOC.OCMode = TIM_OCMODE_PWM1;

   sConfigOC.Pulse = 499U;

   sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;

   //sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;

   sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;

   sConfigOC.OCNIdleState = TIM_OCIDLESTATE_SET;

   sConfigOC.OCNIdleState= TIM_OCNIDLESTATE_RESET;

   if (HAL_TIM_PWM_ConfigChannel(&ConfTimer, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)

   {

      Error_Handler();

   }

   //HAL_TIM_Base_Start(&ConfTimer);

}

VMoca.1
Associate II

Thank you Mike, that was the issue. :)