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.
解決済! 解決策の投稿を見る。
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];
}
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];
}
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.