LPC802 SDK capture example

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC802 SDK capture example

ソリューションへジャンプ
1,625件の閲覧回数
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,452件の閲覧回数
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,453件の閲覧回数
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,452件の閲覧回数
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 件の賞賛
返信