AnsweredAssumed Answered

examples/TIM2/TIM2_Input_Capture/main.c

Question asked by piovan.stefano on Dec 16, 2010
Latest reply on Dec 22, 2010 by lowpowermcu
Hi all,

I was studying the examples on timers and so on.
I came across the source "main.c" in the STM8S Firmware Library package,

examples/TIM2/TIM2_Input_Capture/main.c,

a piece of which is shown below.
This example will show you how to measure the frequency of the LSI.
Although this is very clear what the purpose of activating an interrupt CC1?
/* Enable CC1 interrupt */

00057         TIM2_ITConfig(TIM2_IT_CC1, ENABLE);

I think we'd needn't any interrupt here ?
What do you think?

If you go through the same purposed example presented on TIM1 examples section, infact, there's no interrupt initialization at all...

Thank you
Stefano





void
main(void)
00050 {
00051 
00052         /* Capture only every 8 events!!! */
00053   /* Enable capture of TI1 */
00054         TIM2_ICInit(TIM2_CHANNEL_1, TIM2_ICPOLARITY_FALLING, TIM2_ICSELECTION_DIRECTTI, TIM2_ICPSC_DIV8, 0x00);
00055  
00056         /* Enable CC1 interrupt */
00057         TIM2_ITConfig(TIM2_IT_CC1, ENABLE);
00058        
00059         /* Enable TIM2 */
00060   TIM2_Cmd(ENABLE);
00061                
00062         /* Clear CC1 Flag*/
00063   TIM2_ClearFlag(TIM2_FLAG_CC1);
00064  

Outcomes