STM32 : TIMER modes

stm32f4

I have some questions about timer capture and compare mode in the stm32

What is the role of these modes ?

Can i use compare mode in an application of voice recognition (compare 2 signals)?

Best Answer

1) Input capture mode is used to measure external digital signal. It is capturing a value of an internal counter once input channel transition is detected, thus is able to measure time between input transitions. So basically it allows to measure frequency or duty cycle of an external digital signal. Not analog, which audio signal is.
2) Output Compare mode is just a way to toggle some output pin when compare match is happening. It is good for generating square-wave signal with given parameters (PWM for instance) or just indicate when a given time period elapsed. Nothing to do with oudio as well.