LpcOpen Input Capture lpc111x

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

LpcOpen Input Capture lpc111x

1,373 Views
walterbuttazzo
Contributor II

Hi all,

I'd like to capture a falling edge in PIO3_3 of lpc1115, but my debug session doesn't enter in interrupt Handler

Here is my code:

Init

#define DEMODULATOR_TIMER LPC_TIMER16_0
#define DEMODULATOR_TIMER_IRQ TIMER_16_0_IRQn
#define DEMODULATOR_TIMER_CAPTNUM 0
#define DEMODULATOR_TIMER_IRQHandler TIMER16_0_IRQHandler
#define DEMODULATOR_TIMER_MATCHNUM 0
#define DEMODULATOR_TIMER_MC_VALUE 40000

/* Pin Setting */
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO3_3, IOCON_FUNC2 | IOCON_DIGMODE_EN | IOCON_HYS_EN); 
Chip_GPIO_SetPinDIRInput(LPC_GPIO, 3, 3);
/* Init Timer */
Chip_TIMER_Reset(DEMODULATOR_TIMER);
/* Reset Timer */
/* Ftimer = Fck/12 -> 48MHz/12 = 4MHz */
Chip_TIMER_PrescaleSet(DEMODULATOR_TIMER, 11);
/* Falling edge */
Chip_TIMER_CaptureFallingEdgeEnable(DEMODULATOR_TIMER, DEMODULATOR_TIMER_CAPTNUM);
/* Enable INT */
Chip_TIMER_CaptureEnableInt(DEMODULATOR_TIMER, DEMODULATOR_TIMER_CAPTNUM);

Chip_TIMER_MatchEnableInt(DEMODULATOR_TIMER, DEMODULATOR_TIMER_MATCHNUM);

Chip_TIMER_ClearMatch(DEMODULATOR_TIMER, DEMODULATOR_TIMER_MATCHNUM);

Chip_TIMER_SetMatch(DEMODULATOR_TIMER, DEMODULATOR_TIMER_MATCHNUM, DEMODULATOR_TIMER_MC_VALUE);

/* Start timer */
Chip_TIMER_Enable(DEMODULATOR_TIMER);
/* Turn on int */
NVIC_SetPriority(DEMODULATOR_TIMER_IRQ, 5);

NVIC_EnableIRQ( DEMODULATOR_TIMER_IRQ);

/* IRQ Handler*/

void DEMODULATOR_TIMER_IRQHandler(void)
{
if (Chip_TIMER_CapturePending(DEMODULATOR_TIMER, DEMODULATOR_TIMER_CAPTNUM))
{

Chip_TIMER_ClearCapture(DEMODULATOR_TIMER, DEMODULATOR_TIMER_CAPTNUM);

}

else if (Chip_TIMER_MatchPending(DEMODULATOR_TIMER, DEMODULATOR_TIMER_MATCHNUM))

Chip_TIMER_ClearMatch(DEMODULATOR_TIMER, DEMODULATOR_TIMER_MATCHNUM);
}

Interrupt occur but for match compare ONLY.

With my oscilloscope I can see in PIO3_3 the input square wave

Any Ideas?

Thank a lot

Labels (2)
0 Kudos
Reply
5 Replies

1,053 Views
walterbuttazzo
Contributor II

Thanks Ping, but I created a workaround.

There is no example in example list for Input Capture, that's why I think this function with LpcOpen is not tested.

As workaround I used that Pin as external interrupt pin.

So, I start a normal timer just as a counter end it fires an interrupt on match compare.

As external interrupt, instead of using that timer I use pin.

It works, That's all.

The only disadvantage for this method is I use 2 resources for one target, but to be honest, I don't care :smileyhappy:

Thanks for your support!

Walter

PS

Just one question, are you testing it with hardware or you are just reading the code?

Because reading the code for me everything is Ok, but practically doesn't work :smileysad:

0 Kudos
Reply

1,053 Views
walterbuttazzo
Contributor II

Nope :smileysad:

Same behavior. Enter in ISR Handler, but for Match ONLY, never for Capture

0 Kudos
Reply

1,053 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Walter Buttazzo,

It seems so weird, and I was wondering if you can share the values of CT16B0/1 registers.
It would be easily to figure out some wrong with the CT16B0/1's configuration.

I'm looking forward to your reply.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,053 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Walter Buttazzo,

Please have a try with the codes below.

/* Pin Setting */

Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO3_3, IOCON_FUNC2);

//Chip_GPIO_SetPinDIRInput(LPC_GPIO, 3, 3);


Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,053 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Walter Buttazzo,

Thanks for your sharing, and I'll use the codes above to create a project.

And I'll inform you ASAP I work it out.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply