Yahoo Groups archive

Lpc2000

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

Message

Re: Reading the frequency

2005-06-08 by dukearmlover

--- In lpc2000@yahoogroups.com, "soren_t_hansen" <
soren_t_hansen@y...> 
wrote:
> Hi Group
> 
> Is it possible to read a register or read a pin to see what
frequency
> the processor is running at? I would like to make sure, that my
> LPC2132 is running at the maximum 60 Mhz.
> 
> I have a Xtal of 12 Mhz and have set the PPL to 5, thus giving 60 
Mhz,
> but how can I make sure ....?
> 
> Best Regards
> Søren

Hello,

I had exactly the same problem. Running my very first program on a 
LPC2129 - Olimex LPC-P2129 (using GCC4.0.0) gave me exactly the same 
impression. I was not sure the PLL settings were correct because 
the 'blinking led' was blinking slower than expected.

On some LPC2000 derivatives (e.g. the LPC2214 in 144-pin package),
you 
have the possibiliy to configure one special XCLK pin to generate an 
image of the internal clock.

On the LPC2132, and also on my LPC2129, this pin is not implemented. 
But there is a workaround (what I did). You can e.g. configure the
PWM 
unit to generate a square wave that is proportional to the clock. If 
you set the VPBDIV factor to 1, the PWM prescaler to 0, and use a PWM 
cycle (register PWMMR0) of 1000, with channel 1 at 50% duty cycle 
(PWMMR1 = 500), you will get a square wave at exactly 60 kHz for
60MHz 
clock frequency. This is a way to implement a frequency division by a 
factor 1000.

When I checked the waveform on the pin with an oscilloscope, I
noticed 
the frequency was 14.7 kHz instead, denoting a wrong PLL factor in my 
case. After code inspection, I found a mistake in the macros I used
to 
program the PLL (missing left shift by 5 bits to align correctly a 
bitfield). Correcting the macro gave the correct result.

So the method works !

Regards.

"Duke"

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.