How to drive LPC1768 on 100 Mhz? By default it runs on which clock frequency?

27 Jun 2012

I want know that how to change the clock frequency to 100 Mhz from its default setting? To obtain high speed processing from this controller.

27 Jun 2012

Have a look at Ivo van Poortens 'fast' library http://mbed.org/users/Ivop/libraries/fastlib/m385q5

If you include this lib you can set the frequency like this:

    #include "fastlib/clock.h"

    init_pll0(FL_PLL0_CLOCK_SOURCE_MAIN, 2, 25, 3); // 100MHz

The library has some more neat features to set individual clock frequencies for the pheriperals.

29 Jun 2012

i call this header file and compile program then i get this below error. and in this compiler automatically find the header file so that we don't need to put it in the same path of main program. other things is that in above function, what are the term represent by 2,25,3?

is it must to write this function in side main program?.

"cannot open source input file "fastlib/clock.h": No such file or directory" in file "/main.cpp", Line: 4, Col: 26

please kindly help me..

29 Jun 2012

Hi Tejas,

The processor runs at 96 MHz by default, so there really is not much to gain for 'high speed processing'. If that is your only concern, then my advice is: don't bother.

However, if there is some other reason, like a need for a specific (derived) clock frequency, then you can use the code already provided by Gert (copy the library from the given address), or you can just do it directly yourself:

#include "mbed.h"

void setpll()
{
// the MBED crystal oscillator is 12 MHz
// main oscillator frequency 300 MHz: M = (300 x N) / (2 x 12)
n=2;
m=25;
// processor clock 100 MHz = 300 MHz / D
d=3;
// disconnect
LPC_SC->PLL0CON=0x00000001; pllfeed();
// disable
LPC_SC->PLL0CON=0x00000000; pllfeed();
// set new PLL values
LPC_SC->PLL0CFG=((n-1)<<16)|(m-1); pllfeed();
// enable
LPC_SC->PLL0CON=0x00000001; pllfeed();
// set cpu clock divider
LPC_SC->CCLKCFG=d-1;
// wait for lock
while (LPC_SC->PLL0STAT&0x04000000==0);
// connect
LPC_SC->PLL0CON=0x00000003; pllfeed();
}

void pllfeed()
{
__disable_irq();
LPC_SC->PLL0FEED=0x000000aa;
LPC_SC->PLL0FEED=0x00000055;
__enable_irq();    
}

Notice, that there are many correct combinations of n, m and d to achieve the desired PLL frequency.

02 Jul 2012

thank you sir .

actually, reason behind to ask this que is that, if i try to generate 1 u sec pulse in controller than it failed to give me

accurate pulse of 1 u sec. It gives 1.5 u sec pulse in place 1u sec.

so, I concluded that if it work on the 96 Mhz than it has to give me accurate pulses. but it not so I think, it not work on

96 Mhz or 100 mHz.

what do think sir about it?

i wann use it in sensor less vector control drives.

02 Jul 2012

mbed is able of producing pulses of about 40 nanoseconds , using the normal sequence pinX =0 , pinX =1 , pinX = 0 . you could share the suspected code and ask for suggestions

03 Jul 2012

Gert van der Knokke wrote:

Have a look at Ivo van Poortens 'fast' library http://mbed.org/users/Ivop/libraries/fastlib/m385q5

If you include this lib you can set the frequency like this:

    #include "fastlib/clock.h"

    init_pll0(FL_PLL0_CLOCK_SOURCE_MAIN, 2, 25, 3); // 100MHz

The library has some more neat features to set individual clock frequencies for the pheriperals.

I have compile this code but it shows me the following error.

  1. include "mbed.h"
  2. include "fastlib/clock.h" DigitalOut myled(LED1);

int main() {

while(1) { init_pll0(FL_PLL0_CLOCK_SOURCE_MAIN, 2, 25, 3); 100MHz myled = 1; wait(0.2); myled = 0; wait(0.2); } }

Error is as following

"identifier "init_pll0" is undefined" in file "/main.cpp", Line: 8, Col: 4

if i run this code without this header file and init_pll0(FL_PLL0_CLOCK_SOURCE_MAIN, 2, 25, 3); 100MHz then..

By default i get on time of port 2.5 us and off time 1 us that i should get both 1us..

03 Jul 2012

/media/uploads/tejaspanchal/2012-07-03-518.jpg <<quote bitman>> mbed is able of producing pulses of about 40 nanoseconds , using the normal sequence pinX =0 , pinX =1 , pinX = 0 . you could share the suspected code and ask for suggestions <</quote>>

The code is as following which gives me the on time of 2.5 us and off time of 1.2. That i should get 1 us.

It gives me accurate timing if delay is more then 3 us. but not below 2 us. /media/uploads/tejaspanchal/2012-07-03-518.jpg

  1. include "mbed.h" DigitalOut myled(p24);

int main() {

while(1) { int M=1; myled = 1; wait_us(M); myled = 0; wait_us(M); } }

03 Jul 2012

I don't know how accurate those wait statements will be at their minimum time, but you probably want to use FastOut library, or even better directly address the port registers.

03 Jul 2012

Hi Tejas,

You cannot get this short 'accurate' pulses with software! At least not with a compiled language like C. What's worse, you cannot even get accurate LONG pulses with software, unless the 'accuracy' means relative accuracy.

The processor is running at 96 MHz, but the interrupt on which the wait_us() is relying runs only at 1 MHz. Then there are varying delays associated with the interrupt calling and the wait_us() internal state after return from the interrupt. This gives you inaccuracy. If you want, you can probably increase the interrupt frequency a little bit, but this is by no means the solution.

The correct way to generate accurate pulses is with hardware timers. Then the pulses will be accurate to the crystal accuracy. It is not that hard to do, and a great way to learn more.

BTW, if you want to output regular pulses of some accurate duration, you could use the PwmOut object. It is likely to be based on hardware.

15 Nov 2013

Hi,

Sorry if I'm hijacking this thread (if so, I'll raise it as a new question)...but it is (kind of) related.

Is it actually possible to change the CPU (and peripheral) clock speeds after the initial settings have been made?

I'm trying to find out if that may be an option to reduce the power requirements of the module in certain operational situations (but where we can't allow the processor to go into a power-saving mode).

Hoping that someone out there has already found a way to do this - I'm trying to get it to work at the moment but have not managed it yet.

I'll try & post my current attempt in a few minutes/over the weekend...

Cheers,

Jez