Problem with Input Capture in STM32F103RBT6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-08-22 6:25 AM
Hi all!
I'm using STM32F103RBT6, board Olimex STM32-H103 and i'm trying to create an IR receiving firmware. I'm using Input Capture mode TIM1-Channel1 with the specs below: /*/*/*/*/*/*/*/*/*/*/*/*/*/*/ TIM_ICInitTypeDef TIM_ICInitStructure; 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 = 0xf; TIM_ICInit(TIM1, &TIM_ICInitStructure); /* Enable the CC1 Interrupt Request */ TIM_ITConfig(TIM1, TIM_IT_CC1, ENABLE); /* TIM1 enable counter */ TIM_Cmd(TIM1, ENABLE); /*/*/*/*/*/*/*/*/*/*/*/*/*/*/ and the NVIC specs: /*/*/*/*/*/*/*/*/*/*/*/*/*/*/ NVIC_InitTypeDef NVIC_InitStructure; /* Enable the TIM1 global Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = TIM1_CC_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); /*/*/*/*/*/*/*/*/*/*/*/*/*/*/The problem is: the TIM1 CC interrupt handler is being called every time i connect the PA.8 (which is internally linked to TIM1-CH1) with a floating wire. #input-capture #stm32f103rbt6
- Labels:
-
STM32F1 Series
-
TIM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-08-22 7:37 AM
So why do you think that a floating wire that probably has an electrostatic charge or is picking up RF would not trigger an interrupt ? And what is the significance in your IR application of using a floating wire?
Cheers, Hal- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-08-23 12:34 AM
First thx for attention :)
Second I was just testing the hardware with many ways not just the floating wire. Third, the problem solved , thx a lot:)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-08-23 7:57 AM
Another Problem:(
I've found that it just sees the first falling or rising edge, while my signal is a chain of pulses that i want to know the time between an edge and the one comes next. What can i do?? quick reply please!!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-08-23 8:50 AM
First you need to read the All Densities Reference Manual section on timer capture mode to get a basic understanding of how capture works. Then in your interrupt service routine, you read the timer register value at each interrupt, subtract the previous register value and compute a time difference based on the timer frequency. You need some logic to cater to timer register overflows between captures.
See the timer capture examples that come with the Standard Peripheral Library for more hints. Cheers, Hal- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-08-25 12:38 AM
I've already done all of that, and what i figured out that TIM_GetCapture just takes the first edge of the chain and ignores any come after that.
I need a solution!!!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-08-25 5:30 AM
I presume you haven't posted a complete program because it is proprietary or too large. Create a test program that does only the capture function and see if that works. If it doesn't work, post it in the forum for review.
Cheers, Hal- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-08-25 5:56 AM
Yes, i'm running on a test program already, but the problem was in the repeat pulses that i've not taken into my account so the program was making a lot of tricks and illogical things, i'm on my way now to solve it and enhance the code, thx a lot for your attention bro :)
