CTimer capture examples for LPC54608

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CTimer capture examples for LPC54608

Jump to solution
2,983 Views
timhuang
Contributor II

Anyone can provide examples on how to use ctimer capture function on LPCXpresso54608 board?

I cannot find any examples on the SDK.

Because I would like to detect our power button is short press or long press.

Could you give us some suggestions?

Thank you.

Labels (1)
1 Solution
2,590 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi timhuang,

     Yes, we still don't have the directly CTimer capture examples for LPC54608 in the SDK, but don't worry, actually, it is not difficult.

     You can follow my way to try it, just modify the simple_match_interrupt code.

     1. pin_mux.c

         Add the capture pin which you want to used, you need to define the according pin, please note the FUN, you need to choose the according capture function.

     2.  In main.c

        You need to comment the match config code, and CTIMER_SetupMatch code.

       You can add setup capture code:

void CTIMER_SetupCapture(CTIMER_Type *base,
                         ctimer_capture_channel_t capture,
                         ctimer_capture_edge_t edge,
                         bool enableInt)

  eg.CTIMER_SetupCapture(CTIMER,kCTIMER_Capture_0,kCTIMER_Capture_BothEdge,true);

  This code configure capture 0 as the capture channel, the capture edge is both edge, enable the interrupt.

   Then in the CTIMER interrupt handler function, add :CTIMER_ClearStatusFlags, and read the CR[0:3] register value.

You can try it on your side, this function is very easy to realize it.

If you still have question about it, just let me know.


Have a great day,
Kerry

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

View solution in original post

4 Replies
2,591 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi timhuang,

     Yes, we still don't have the directly CTimer capture examples for LPC54608 in the SDK, but don't worry, actually, it is not difficult.

     You can follow my way to try it, just modify the simple_match_interrupt code.

     1. pin_mux.c

         Add the capture pin which you want to used, you need to define the according pin, please note the FUN, you need to choose the according capture function.

     2.  In main.c

        You need to comment the match config code, and CTIMER_SetupMatch code.

       You can add setup capture code:

void CTIMER_SetupCapture(CTIMER_Type *base,
                         ctimer_capture_channel_t capture,
                         ctimer_capture_edge_t edge,
                         bool enableInt)

  eg.CTIMER_SetupCapture(CTIMER,kCTIMER_Capture_0,kCTIMER_Capture_BothEdge,true);

  This code configure capture 0 as the capture channel, the capture edge is both edge, enable the interrupt.

   Then in the CTIMER interrupt handler function, add :CTIMER_ClearStatusFlags, and read the CR[0:3] register value.

You can try it on your side, this function is very easy to realize it.

If you still have question about it, just let me know.


Have a great day,
Kerry

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

2,479 Views
marticarlo
Contributor I

Hi Support,

so till now there is no way in any micro supported by mcuexpresso (also the last family LPC550x) to setup an CTIMER input capture pin parameters directly in the user interface but it is necessary starting from an example and modify by hands the source code. Is it correct? 

0 Kudos
2,590 Views
timhuang
Contributor II

We follow your teaching,

it's for implement the CTimer Capture function very helpful,

it look like work fine now.

Thanks for your great technical support,

Best Regards,

Tim

0 Kudos
2,590 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Tim,

    You are welcome, if it works, please help to mark the correct answer, just to close this case, thank you!


Have a great day,
Kerry

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

0 Kudos