lpcware

Counting on a GPIO input pin

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by raimond on Sat Mar 12 01:40:24 MST 2011
Hi all,

Anybody knows about any issue about GPIO input pin reading on an interrupt? I have an application which need a frequency meter. The frequency is measured first sampling the input pin on a timer interrupt, detecting the edges by software, and then, the counter is reported to the second, on another timer interrupt.

The issue: I always have a few additional edges detected, for example, at 100Hz signal I have 100-106 Hz measured, not constant. Never 99 !

I suspected the gpio input not having schmitt-trigger driver, I added an external schmitt-trigger, no luck.

Frequency sampling: 10kHz. Input pin: P1.0. With P1.1 the same.

My application is a very mature one, I have done it on a Rabbit2000, Z8encore, and now I want to port it on an LPC1756. On previous micros I always got 100Hz sharp, not the LPC1756 case :(. I even have done an ATmega64 test, 100Hz sharp again.

I'm going to loose my confidence about the LPC17xx.

By the way, I use a good 12MHz crystal, and I'm working at 12Mhz without PLL. Pclk is 3MHz.

I have done many things, using the same timer for scanning/second reporting, using timer0, timer1, RIT..., disabling ints, enabling ints, using the input in all four modes...

By the way, when scanning at 400Hz, I get the 100Hz indeed, but there's no use, because I have to detect frequencies till 4kHz.

Any ideas?

Outcomes