Timer in gated mode
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-02-17 3:46 AM
Posted on February 17, 2012 at 12:46
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:{) #timer-gated
Labels:
- Labels:
-
TIM
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-02-23 5:44 AM
Posted on February 23, 2012 at 14:44
Do you have enabled
the device
?
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2012-02-27 5:02 PM
Posted on February 28, 2012 at 02:02 Hi Siqueira, Thanks for the suggestion, but I have the clock enabled. I've not been able to progress with it. ...Laurie:{)
