cancel
Showing results for 
Search instead for 
Did you mean: 

TIM6 setting in stm32cubemx

Md Mubdiul Hasan
Associate III
Posted on October 13, 2016 at 06:57

Dear All,

I am working in STM32F070R8T6.

For the Timer base pwm generation I need to use TIM6, I have no option for choosing TIM1 and TIM2.

I need to activate internal pwm which may cause by pressing GPIO key button.

 

Kindly, help me to set TIM6 in stmcubemx.
2 REPLIES 2
Nesrine M_O
Lead II
Posted on October 13, 2016 at 12:12

Hi hasan.md_mubdiul,

''I am working in STM32F070R8T6.

For the Timer base pwm generation I need to use TIM6, I have no option for choosing TIM1 and TIM2?

I guess that you use STM32F070RBT6 (not STM32F070R8T6), and you don?t have option for choosing TIM1 and TIM3 (not TIM1/2)

TIM6/7 are basic timers witch don?t feature independent channel for PWM generation so you cannot use them.

As shown in this figure you can use TIM14/15/16/17

0690X00000604vyQAA.png

-Syrine-

Md Mubdiul Hasan
Associate III
Posted on October 14, 2016 at 02:17

Dear Sir Syrine,

Thank you very much, I saw this in datasheet that TIM6/7 will not be use for this MCU.

My circuit does not contain any external TIMER I/O port. That means, I have to activate internal timer.

0690X00000604w3QAA.png

This setting generates, 

static void MX_TIM14_Init(void)

     {

       TIM_IC_InitTypeDef sConfigIC;

       htim14.Instance = TIM14;

       htim14.Init.Prescaler = 0;

       htim14.Init.CounterMode = TIM_COUNTERMODE_UP;

       htim14.Init.Period = 0;

       htim14.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

       if (HAL_TIM_Base_Init(&htim14) != HAL_OK)

       {

         Error_Handler();

       }

       if (HAL_TIM_IC_Init(&htim14) != HAL_OK)

       {

         Error_Handler();

       }

       if (HAL_TIM_OnePulse_Init(&htim14, TIM_OPMODE_SINGLE) != HAL_OK)

       {

         Error_Handler();

       }

       sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_RISING;

       sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;

       sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;

       sConfigIC.ICFilter = 0;

       if (HAL_TIM_IC_ConfigChannel(&htim14, &sConfigIC, TIM_CHANNEL_1) != HAL_OK)

       {

         Error_Handler();

       }

       if (HAL_TIMEx_RemapConfig(&htim14, TIM_TIM14_MCO) != HAL_OK)

       {

         Error_Handler();

       }

My aim is to apply this timer along with pwm and use it by press key.

Kindly, refer me any helpful example source code.

Regards

Hasan