Hi vikram846,
I am also working on the completely same issue and I could get a PWM signal with the following code (only the main part). I added a call of InitPWM() in the Application_Ini() function and my Primer2 output a 144Hz PWM signal with a duty ratio of 0.8.
Of course, as yrt mentioned above, you have to add the ".c" files in your project first.
#It is only and the worst feature of the Ride 7 environment...
void InitPWM(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
uint16_t PWM1_Width = 400;
TIM_Cmd(TIM2, DISABLE);
RCC_AHBPeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_AHBPeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
// Configure PA.0 (TIM2_CH1_ETR)
// TIM2_CH1_ETR is connected to the pin 14 of the ext. terminal of Primer2
// as a floating input
GPIO_StructInit (&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0; // PA.0 = the pin 14 of the ext. terminal
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Prescaler = 999;
TIM_TimeBaseStructure.TIM_ClockDivision = 0; // 72M/(0+1)=72M
TIM_TimeBaseStructure.TIM_Period = 500; // generates 72M/(Prescaler+1)/(ClockDivision+1)/Period)
TIM_TimeBaseStructur/500=e.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
/* PWM1 Mode configuration */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = PWM1_Width;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init(TIM2, &TIM_OCInitStructure);
TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Enable);
/* TIM enable counter */
TIM_Cmd(TIM2, ENABLE);
}