Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: [lpc2000] Timer as counter...

2006-05-23 by Karl Olsen

---- Original Message ----
From: "Andrew Berney" <amb@...>
To: <lpc2000@yahoogroups.com>
Sent: Tuesday, May 23, 2006 5:26 PM
Subject: [lpc2000] Timer as counter...

> Just a quick question to see if there's anyway of using the inbuilt
> timer functionality of a LPC2119 as a counter. Ie to count the number
> pulses (rising or falling edge) from an external source over a given
> time frame. Basically we have a pot that changes a source input
> frequency from 36khz to around 48khz and driving an IRQ for each
> pulse doesn't strike me as being a good idea. All I need to
> realistically know is roughly what frequency it's being driven at.

Being able to count rising and/or falling edges on the CAPx.x pins was added
to LPC213x and newer.  The timer hardware of the LPC2119 cannot.

Connecting your signal to an interrupt pin, and incrementing a counter in
the interrupt handler will take a few percent performance.

You may be able to misuse some other peripherals to get a lower interrupt
rate.  For example, configure SPI to slave mode, and connect your signal to
SCKx, and you'll get an interrupt every eighth clock.

Or maybe configure a UART to a suitably high baudrate and FIFO with trigger
level 14, and connect your signal to RxD.  The UART should detect every
falling edge as the start of a new incoming byte, and at every 14th edge,
you should get a FIFO full interrupt.  The baudrate should not be so high
that you get character timeout interrupts.

You can also connect your signal to both a CAPx.0 and a CAPx.1 pin, and
capture CR0 on rising edges and CR1 on falling edges.  You can then always
check the half-period time by looking at CR0 and CR1.  This requires no
interrupts at all.

Karl Olsen

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.