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

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Jump to solution
676 Views
kdn
Contributor III

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 */

}

Labels (1)
Tags (1)
0 Kudos
1 Solution
197 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi KDN,

I am not sure if i understand your question.

when you add Capture component to a project,  Capture mode is enabled by default.

when you want disable capture mode, you can execute

Cap1_Disable()

in your code .

when you want enable it again, you execute

Cap1_Enable()

does it make sense?


Have a great day,
Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
6 Replies
198 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi KDN,

I am not sure if i understand your question.

when you add Capture component to a project,  Capture mode is enabled by default.

when you want disable capture mode, you can execute

Cap1_Disable()

in your code .

when you want enable it again, you execute

Cap1_Enable()

does it make sense?


Have a great day,
Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
197 Views
kdn
Contributor III

How can I set timer in interrupt for 10m sec

10-07-2015.png

0 Kudos
197 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

hi KDN

I am afraid this mc9s12xhz chip doesn't support FreeCntr component.

Please use TimerInt component to set 10ms interrupt

2015-07-11_0-24-30.png

can this help?

Have a great day,

Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
197 Views
kdn
Contributor III

If I run API periodic interrupt timer my Input capture mode not work

0 Kudos
197 Views
kdn
Contributor III

This FreeCntr component is shared with input capture mode time , I need separate timer

0 Kudos
197 Views
kdn
Contributor III

I have connected 3 PWM channel On input capture pin for reading duty cycle of signal, I want to read them one by one in interrupt mode.

0 Kudos