Author Topic: STM32F103 PWM timer3 output  (Read 3052 times)

0 Members and 1 Guest are viewing this topic.

Offline icamasterTopic starter

  • Contributor
  • Posts: 17
  • Country: gb
STM32F103 PWM timer3 output
« on: January 15, 2017, 08:09:10 pm »
I am trying to generate a clock of 1.4MHz using the STM32F103C8Tx using the STM32CubeMX.

First of all, in my code I have pin PB13 as output and in main I toggle it every one second. This works.

Now the more important part. Things I have set up in CubeMX :

I have set up the base clock of the device to 28MHz.
TIM3 Channel2 :PWM Generation CH2
Internal Clock
Timer3 :


Here is the code :
https://gist.github.com/icamaster/e45649478a2e01d5beb46f4313e79e9c

Apart from the generate part, I have added these lines before the while(1) in the main :
  HAL_TIM_PWM_MspInit(&htim3);
  HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_2);

Where the *_MspInit function is :
Code: [Select]
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
{

  if(htim_pwm->Instance==TIM3)
  {
  /* USER CODE BEGIN TIM3_MspInit 0 */

  /* USER CODE END TIM3_MspInit 0 */
    /* Peripheral clock enable */
    __HAL_RCC_TIM3_CLK_ENABLE();
  /* USER CODE BEGIN TIM3_MspInit 1 */

  /* USER CODE END TIM3_MspInit 1 */
  }

}

The LED is blinking at the set interval but I have no output on the pin A7 (Timer3 channel 2). This is verified on the oscilloscope.
 

Offline Brutte

  • Frequent Contributor
  • **
  • Posts: 614
Re: STM32F103 PWM timer3 output
« Reply #1 on: January 15, 2017, 08:25:14 pm »
Cross post warning  :--
 
The following users thanked this post: thm_w

Online newbrain

  • Super Contributor
  • ***
  • Posts: 1687
  • Country: se
Re: STM32F103 PWM timer3 output
« Reply #2 on: January 15, 2017, 11:11:51 pm »
Look carefully at you setup value for period and pulse and their meaning.
Nandemo wa shiranai wa yo, shitteru koto dake.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf