LPC802 SDK capture example

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

LPC802 SDK capture example

Jump to solution
1,322 Views
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.

Labels (1)
1 Solution
1,149 Views
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];
}

View solution in original post

2 Replies
1,150 Views
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,149 Views
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 Kudos