cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103RET6 PWM

Ephraim Oved
Associate
Posted on April 25, 2017 at 19:49

Dear Sir .

I am configuring A8,A9,A10,A11 for PWM OUTPUT.

I don't get an pwm output on PA9 , 

If I configure PA9 as output , Than I can toggle it.

Attached some code

/* Configure PWM Outputs */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_Init(GPIOA, &GPIO_InitStructure);

// Enable TIM1 clock

RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1, ENABLE);

// Time Base configuration

TIM_TimeBaseStructure.TIM_Prescaler = 0x0;

TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

TIM_TimeBaseStructure.TIM_Period = 0x3FF; // 10 bit

TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;

TIM_TimeBaseStructure.TIM_RepetitionCounter = 0x0;

TIM_TimeBaseInit(TIM1 , &TIM_TimeBaseStructure);

// Channel 1,2 Configuration in PWM mode

TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;

TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;

TIM_OCInitStructure.TIM_OutputNState = TIM_OutputNState_Enable;

TIM_OCInitStructure.TIM_Pulse = 0x3ff;

TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;

TIM_OCInitStructure.TIM_OCNPolarity = TIM_OCNPolarity_Low;

TIM_OCInitStructure.TIM_OCIdleState = TIM_OCIdleState_Set;

TIM_OCInitStructure.TIM_OCNIdleState = TIM_OCIdleState_Reset;

TIM_OC1Init(TIM1,&TIM_OCInitStructure);

TIM_OCInitStructure.TIM_Pulse = 0x100;

TIM_OC2Init(TIM1,&TIM_OCInitStructure);

TIM_OCInitStructure.TIM_Pulse = 0x200;

TIM_OC3Init(TIM1,&TIM_OCInitStructure);

TIM_OCInitStructure.TIM_Pulse = 0x2ff;

TIM_OC4Init(TIM1,&TIM_OCInitStructure);

// TIM1 counter enable

TIM_Cmd(TIM1,ENABLE);

// Main Output Enable

TIM_CtrlPWMOutputs(TIM1,ENABLE);

Please Advise

1 REPLY 1
Posted on April 26, 2017 at 04:18

Remap UASRT1 off these pins

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..