AnsweredAssumed Answered

Timer in gated mode

Question asked by net_id on Feb 17, 2012
Latest reply on Feb 28, 2012 by net_id
I need to read from a zacwire device into the STM32.
I thought I could achieve this by using TIM2 setup in gated mode.
The idea was that I could then time the length of the start bit ( 1/2 bit length low pulse) and use that to sample subsequent bits.
I have PA.0 (TIM2_CH1) set as floating input.
I was expecting to see TIM2_CCR1 as the value of the capture caught in the interrupt but the interrupt is not called and CCR1 does not change when view with uVision.
This is what I have setup:

TIM_ICInitStructure.TIM_ICMode = TIM_ICMode_ICAP;
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;
TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Falling;
TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;
TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;
TIM_ICInitStructure.TIM_ICFilter = 0x0;
TIM_ICInit(TIM2, &TIM_ICInitStructure);
TIM_SelectInputTrigger(TIM2, TIM_TS_TI1FP1);
TIM_SelectSlaveMode(TIM2, TIM_SlaveMode_Gated);

TIM_TimeBaseStructure.TIM_Period = 0xFFFF;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM2, & TIM_TimeBaseStructure);

/* Enable the CC2 Interrupt Request */
TIM_ITConfig(TIM2, TIM_IT_CC1, ENABLE);
/* TIM enable counter */

NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = configLIBRARY_KERNEL_INTERRUPT_PRIORITY;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init( &NVIC_InitStructure );

TIM_Cmd(TIM2, ENABLE);


Nothing I've found has helped me.
What am I missing? ...Laurie:{)

Outcomes