AnsweredAssumed Answered

STM32F103 Timer input capture disables USART - problem

Question asked by minthemerciless on Mar 8, 2016
Latest reply on Mar 10, 2016 by minthemerciless
Hi all,

I am new this forum so bear with me.  I am working on a project using an STM32F103RBT6 that incorporates a timer in input capture mode (TIM2) and a USART (USART3).

I can successfully enable the USART and transmit data over a USB to TTL cable to a laptop.

The problem is when I try to set up the timer.  As soon a I include the timer initialisation code using TIM_ICInit, the USART stops working and nothing comes through to the computer.

I'm hoping someone here could shed some light on it.  I'm assuming I have made some school boy error and not realised.

I have included some of my code below.

Thanks in advance

Look forward to hearing from you all.


USART set up:
USART_InitTypeDef USART_InitStructure;
/* set up with baud rate at 115200, Tx and Rx mode */
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART3, &USART_InitStructure);

Timer set up:
TIM_ICInitTypeDef       TIM_ICInitStructure;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_BothEdge;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0x0;
// initialise channel 1
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInit(TIM2, &TIM_ICInitStructure);
/* TIM enable counter */