AnsweredAssumed Answered

STM32F103 Input PWM TIM3_CH3/TIM3_CH4

Question asked by livianamj on Mar 27, 2014
Latest reply on Mar 28, 2014 by Clive One
Hello, I want to capture PWM input with TIM_CH3/TIM3_CH4 is that possible? Because I tried my code, and it cannot be shown when I observed the register either CCR1 for duty cycle or CCR2 for frequency. 

This is my code :
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
 
   RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB);
 
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOB, &GPIO_InitStructure);
 
TIM_ICInitTypeDef  TIM_ICInitStructure;
TIM_TimeBaseInitTypeDef   TIM_TimeBaseStructure;
 
 
    /* Time Base configuration */
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Period = 0xFF0;
TIM_TimeBaseStructure.TIM_Prescaler = 0x22;
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM8, &TIM_TimeBaseStructure);
 
/* TIM3 Channel3 Configuration ---------------------------------------------------*/
TIM_ICInitStructure.TIM_Channel = TIM_Channel_4;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0x0;
TIM_ICInit(TIM8, &TIM_ICInitStructure);
TIM_PWMIConfig(TIM3, &TIM_ICInitStructure);
 
/* Select the TIM3 Input Trigger: TI2FP2 */
TIM_SelectInputTrigger(TIM3, TIM_TS_TI2FP2);
 
/* Select the slave Mode: Reset Mode */
TIM_SelectSlaveMode(TIM3, TIM_SlaveMode_Reset);
 
/* Enable the Master/Slave Mode */
TIM_SelectMasterSlaveMode(TIM3, TIM_MasterSlaveMode_Enable);
 
/* TIM enable counter */
TIM_Cmd(TIM3, ENABLE);
 
/* Enable the CC2 Interrupt Request */
TIM_ITConfig(TIM3, TIM_IT_CC2, ENABLE);
 
TIM_CtrlPWMOutputs(TIM3, ENABLE);
Thank you in advance.

Outcomes