LPC802 SDK capture example

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

LPC802 SDK capture example

跳至解决方案
1,410 次查看
asier
Contributor III

Hi,

I want to measure a square wave from rising edge to falling edge.

Is there any SDK example for using CTIMER as capture ? 

Thanks in advance,

Asier.

标签 (1)
1 解答
1,237 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Asier,

I have checked  the examples in SDK package, I do not think the SDK have example for capture function, but the CTimer module supports capture function exactly.

For LPC802, if you can connect the captured signal to pin for example PIO0_12.

I suppose that you can use the code to get the captured value, you can set the CTimer modulo as large as possible.

Hope it can help you

BR

XiangJun Rong

ctimer_callback_t ctimer_callback_table[] = {
    NULL, NULL, NULL, NULL, ctimer_cap0_callback, NULL, NULL, NULL};

//use the PIO0_12 as T0_cap0 signal
void capInit(void)
{
    SYSCON->SYSAHBCLKCTRL0|=1<<7; //enable SWM clock
    SWM0->PINASSIGN.PINASSIGN3=12<<8;
    CTIMER_SetupCapture(CTIMER,0,kCTIMER_Capture_RiseEdge,true);
    CTIMER_RegisterCallBack(CTIMER, &ctimer_callback_table[0], kCTIMER_MultipleCallback);

}
uint32_t captureValue0;
void ctimer_cap0_callback(uint32_t flags)
{
    //read the capture value
    captureValue0=CTIMER->CR[0];
}

在原帖中查看解决方案

2 回复数
1,238 次查看
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Asier,

I have checked  the examples in SDK package, I do not think the SDK have example for capture function, but the CTimer module supports capture function exactly.

For LPC802, if you can connect the captured signal to pin for example PIO0_12.

I suppose that you can use the code to get the captured value, you can set the CTimer modulo as large as possible.

Hope it can help you

BR

XiangJun Rong

ctimer_callback_t ctimer_callback_table[] = {
    NULL, NULL, NULL, NULL, ctimer_cap0_callback, NULL, NULL, NULL};

//use the PIO0_12 as T0_cap0 signal
void capInit(void)
{
    SYSCON->SYSAHBCLKCTRL0|=1<<7; //enable SWM clock
    SWM0->PINASSIGN.PINASSIGN3=12<<8;
    CTIMER_SetupCapture(CTIMER,0,kCTIMER_Capture_RiseEdge,true);
    CTIMER_RegisterCallBack(CTIMER, &ctimer_callback_table[0], kCTIMER_MultipleCallback);

}
uint32_t captureValue0;
void ctimer_cap0_callback(uint32_t flags)
{
    //read the capture value
    captureValue0=CTIMER->CR[0];
}

1,237 次查看
asier
Contributor III

Hi Xiangjun,

I think it is needed "CTIMER_StartTimer(CTIMER);" line after registercallback definition in your example.

I got it to work.

Thank you so much,

Asier.

0 项奖励