CTimer capture examples for LPC54608

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

CTimer capture examples for LPC54608

跳至解决方案
3,088 次查看
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.

标签 (1)
1 解答
2,695 次查看
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!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

4 回复数
2,696 次查看
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,584 次查看
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 项奖励
2,695 次查看
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 项奖励
2,695 次查看
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 项奖励