Capture
 
Component Capture
Timer capture encapsulation
Component Level: Low
Typical Usage:
(Examples of a typical usage of the component in user code. For more information please see the page Component Code Typical Usage.)

Required component name is "Cap1".

The following example waits for the first captured value:

 MAIN.C

void main(void)
{

  Cap1_Reset(); /* reset the counter */
  err=1;

  /* wait until captured value is written to variable Data */
  while(err!=ERR_OK);   

}
 EVENTS.C
word Data;
byte err;

void Cap1_OnCapture(void)
{
  /* Write captured value to variable Data */
  err=Cap1_GetCaptureValue(&Data);
}

Capturing with Interrupt service/event disabled

The following example shows possibility of capture in polling mode. There are no events in the component but the status of input capture can be obtained by GetStatus method.

    
 MAIN.C

void main(void)
{ 
  word Data;
  byte err;

  Cap1_Reset(); /* reset the counter */

  for(;;) { /* infinite loop */
   
       
    if (Cap1_GetStatus()) { /* get input capture status */    
    
      /* Write captured value to variable Data */
      err = Cap1_GetCaptureValue(&Data);
      
      /* variable Data contains captured value of a timer */
    }    
    
    ...  /* other main code */
    
  }

}