AnsweredAssumed Answered

How can I enable and disable Input capture mode in code warrior software using this function below generated by Processor expert

Question asked by Ajay Singh on Jul 9, 2015
Latest reply on Jul 11, 2015 by Ajay Singh

byte Cap1_Enable(void)

{

  if (!EnUser) {                       /* Is the device disabled by user? */

    EnUser = TRUE;                     /* If yes then set the flag "device enabled" */

  /* TFLG1: C7F=0,C6F=0,C5F=0,C4F=0,C3F=0,C2F=0,C1F=0,C0F=1 */

    TFLG1 = 0x01U;                     /* Reset interrupt request flag */

    TIE_C0I = 1U;                      /* Enable interrupt */

    TFLG2_TOF = 1U;                    /* Reset overflow interrupt request flag */

    TSCR2_TOI = 1U;                    /* Enable overflow interrupt */

  /* TCTL4: EDG0B=1,EDG0A=1 */

    TCTL4 |= 0x03U;                    /* Enable capture function */

  }

  return ERR_OK;                       /* OK */

}

 

 

/*

** ===================================================================

**     Method      :  Cap1_Disable (component Capture)

**

**     Description :

**         This method disables the component - it stops the capture. No

**         events will be generated.

**     Parameters  : None

**     Returns     :

**         ---             - Error code, possible codes:

**                           ERR_OK - OK

**                           ERR_SPEED - This device does not work in

**                           the active speed mode

** ===================================================================

*/

byte Cap1_Disable(void)

{

  if (EnUser) {                        /* Is the device enabled by user? */

    EnUser = FALSE;                    /* If yes then set the flag "device disabled" */

    TIE_C0I = 0U;                      /* Disable interrupt */

    TSCR2_TOI = 0U;                    /* Disable overflow interrupt */

  /* TCTL4: EDG0B=0,EDG0A=0 */

    TCTL4 &= (uint8_t)~(uint8_t)0x03U; /* Disable capture function */

  }

  return ERR_OK;                       /* OK */

}

Outcomes