cancel
Showing results for 
Search instead for 
Did you mean: 

Remapping of TIM1 pins PROBLEM

davidhauser
Associate II
Posted on July 09, 2009 at 11:02

Remapping of TIM1 pins PROBLEM

3 REPLIES 3
davidhauser
Associate II
Posted on May 17, 2011 at 12:29

Hey

I've got an STM32F103VBH6 processor. Now I'd like to remap the TIM1 pins from ''no remap'' to ''full remap'' and generate a PWM on these pins. I tried it by using the command:

GPIO_PinRemapConfig(GPIO_FullRemap_TIM1, ENABLE);

Without this command I get the PWM signal on the pins of the ''no remap'' configuration. Using this command generates no signal on no pin.

------

Here is my program for the REMAPPED pins (which doesn't work):

------

GPIO_StructInit(&GPIO_InitStructure);

/* TIM1 and GPIOE clock enable */

RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 | RCC_APB2Periph_GPIOE, ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9| GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOE, &GPIO_InitStructure);

GPIO_PinLockConfig(GPIOE, GPIO_Pin_9 | GPIO_Pin_11 | GPIO_Pin_13);

/* Remaping of the TIM1 pins */

GPIO_PinRemapConfig(GPIO_FullRemap_TIM1, ENABLE);

------

This is the program of the NOT REMAPPED pins (which works fine):

------

GPIO_InitTypeDef GPIO_InitStructure;

/* TIM1, GPIOA and GPIOB clock enable */

RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 | RCC_APB2Periph_GPIOA |

RCC_APB2Periph_GPIOB, ENABLE);

/* GPIOA Configuration: Channel 1, 2, 3 and 4 Output */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9| GPIO_Pin_10 | g

GPIO_Pin_11;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOA, &GPIO_InitStructure);

/* GPIOB Configuration: Channel 1N, 2N and 3N Output */

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;

GPIO_Init(GPIOB, &GPIO_InitStructure);

Is there anything I've forgotten? Thanks for help.

[ This message was edited by: davidhauser on 10-04-2008 17:56 ]

smart
Associate II
Posted on May 17, 2011 at 12:29

for remapping you have to enable the AFIO clock if in case you have't done it.

/* AFIO clocks */

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

ozenozkaya
Associate II
Posted on May 17, 2011 at 12:29

i am trying to use TIM3 Channel 1 as PWM from PC6 as AF; but the brigthness doesnt change. what am i doing wrong?? pls help...

here is the code:

RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM3 , ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);

GPIO_InitTypeDef GPIO_InitStructure;

TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;

TIM_OCInitTypeDef TIM_OCInitStructure;

//this pin functions as AF; when remapping

GPIO_PinRemapConfig(GPIO_FullRemap_TIM3, ENABLE);

/*GPIOC Configuration: TIM3 channel 1 */

/* make sure that C port is opened in RCC*/

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOC, &GPIO_InitStructure);

TIM_Cmd(TIM3, DISABLE);

TIM_ARRPreloadConfig(TIM3, ENABLE);

/* Time base configuration */

TIM_TimeBaseStructure.TIM_Period = 999;

TIM_TimeBaseStructure.TIM_Prescaler = 0;

TIM_TimeBaseStructure.TIM_ClockDivision = 0;

TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);

/* PWM1 Mode configuration: Channel1 */

TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;

TIM_OCInitStructure.TIM_Channel = TIM_Channel_1;

TIM_OCInitStructure.TIM_Pulse = 500;

TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;

TIM_OCInit(TIM3, &TIM_OCInitStructure);

TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Enable);

TIM_ARRPreloadConfig(TIM3, ENABLE);

/* TIM3 enable counter */

TIM_Cmd(TIM3, ENABLE);

TIM_SetCompare1(TIM3,0x10);