9 years, 11 months ago.

how to check weather my board runs at 96mhz

hi i want to know how to check the speed of my lpc1768 (i,e) at what speed is it running.. pls anyone help

#include "mbed.h"
#define SYSCLK 96000000
#define EXTCLK 12000000
#define PLLCLK 288000000
#define PLLMULT (PLLCLK/2/EXTCLK)-1
Serial pc(USBTX,USBRX);
void initclock()
{
      pc.printf("in main\n");
      //LPC_SC->CLKSRCSEL =(1<<0); // initize main oscillator
                               
      pc.printf("BREAK 1\n");
      LPC_SC->PLL0CON&=~(1<<1);// /////////////DISCONNECT///////////////
      
      //FED SEQ
      LPC_SC->PLL0FEED =0xAA;
      LPC_SC->PLL0FEED =0x55;
      while ((LPC_SC->PLL0STAT & (1<<25)) != 0x00);
        
      pc.printf("BREAK 2\n");                  /////////////disable previous pll///////////////
      LPC_SC->PLL0CON&=~(1<<0);              /////////DISABLE PLL0///////////////
      //FED SEQ
      LPC_SC->PLL0FEED =0xAA;
      LPC_SC->PLL0FEED =0x55;
      while((LPC_SC->PLL0STAT &(1<<24))!=0x00);
       LPC_SC->CLKSRCSEL|=(1<<0); // initize main oscillator
        
      pc.printf("BREAK 3\n");             
      LPC_SC->PLL0CFG = PLLMULT;        //CCLKCFG VALUE ARE SUBSTITUTED//
      //FED SEQ
      LPC_SC->PLL0FEED =0xAA;
      LPC_SC->PLL0FEED =0x55;
                                 //////////////set enable/////////////
    pc.printf("BREAK4\n");
    LPC_SC->PLL0CON|=(1<<0);
    LPC_SC->PLL0FEED =0xAA;
    LPC_SC->PLL0FEED =0x55;
    while((LPC_SC->PLL0STAT &(1<<24))==0x00);
  
     pc.printf("BREAK 5\n");
     LPC_SC->CCLKCFG =(2<<0); 
      LPC_SC->PLL0FEED =0xAA;
      LPC_SC->PLL0FEED =0x55; ///setting dsiv value and checking if its locked to desired frequency;
     while(LPC_SC->PLL0STAT &(1<<26)==0x00);
   
                              /////////////////////////CONNECT PLL0/////////////////////////
    {    pc.printf("BREAK6\n");
         LPC_SC->PLL0CON|=(1<<1);
         LPC_SC->PLL0FEED =0xAA;
         LPC_SC->PLL0FEED =0x55;
        while(LPC_SC->PLL0STAT &(1<<25)==0x00);
                 }
               }
               
                 ///////////PRINTING D VALUE////////////////////////
         int main()
         {
             initclock();
             wait(1);
         pc.printf("HI\n");
         pc.printf("PLL0CON =0x%08X\n",LPC_SC->PLL0CON);
         pc.printf("PLL0STAT=0x%08X\n",LPC_SC->PLL0STAT);
         pc.printf("PLLCLK =0x%08X\n",LPC_SC->CCLKCFG);
         int value=LPC_SC->PLL0STAT&0x7FFF;
         pc.printf("value %d\n",value);
         SystemCoreClockUpdate();

         pc.printf("%d",SystemCoreClock);
  }
  }

i am trying to set the pll clock i am not able to know if it works at 96mhz i am not able to get any msgs which iam trying to print inside the initclock function i get some junk value then the msg in the main gets printed coorectly can any one suggest me what is the problem and how to check the frequency and i dont have an oscilloscope

1 Answer

9 years, 11 months ago.

Hello,

there's a global system variable called SystemCoreClock, which should reflect the system core clocks. Of course, if you use cmsis API (SystemInit() and SystemCoreClockUpdate()). The LPC1768 should have a dedicated output pin to direct you clock there, which enables you to measure it with a measuring device like oscilloscope. Usually called CLKOUT.

Regards,
0xc0170

Accepted Answer

is der any way to print it bcoz i dont have oscilloscope.. i have wriiten the code in c which i have posted below <<code>>

  1. include "mbed.h"
  2. define SYSCLK 96000000
  3. define EXTCLK 12000000
  4. define PLLCLK 288000000
  5. define PLLMULT (PLLCLK/2/EXTCLK)-1 Serial pc(USBTX,USBRX); void initclock() { pc.printf("in main\n"); LPC_SC->CLKSRCSEL =(1<<0); initize main oscillator

pc.printf("BREAK 1\n"); LPC_SC->PLL0CON&=(1<<1); ///DISCONNECT///

FED SEQ LPC_SC->PLL0FEED =0xAA; LPC_SC->PLL0FEED =0x55; while ((LPC_SC->PLL0STAT & (1<<25)) != 0x00);

pc.printf("BREAK 2\n"); ///disable previous pll/// LPC_SC->PLL0CON&=(1<<0); /DISABLE PLL0/// FED SEQ LPC_SC->PLL0FEED =0xAA; LPC_SC->PLL0FEED =0x55; while((LPC_SC->PLL0STAT &(1<<24))!=0x00); LPC_SC->CLKSRCSEL|=(1<<0); initize main oscillator

pc.printf("BREAK 3\n"); LPC_SC->PLL0CFG = PLLMULT; CCLKCFG VALUE ARE SUBSTITUTED FED SEQ LPC_SC->PLL0FEED =0xAA; LPC_SC->PLL0FEED =0x55; //set enable/// pc.printf("BREAK4\n"); LPC_SC->PLL0CON|=(1<<0); LPC_SC->PLL0FEED =0xAA; LPC_SC->PLL0FEED =0x55; while((LPC_SC->PLL0STAT &(1<<24))==0x00);

pc.printf("BREAK 5\n"); LPC_SC->CCLKCFG =(2<<0); LPC_SC->PLL0FEED =0xAA; LPC_SC->PLL0FEED =0x55; /setting dsiv value and checking if its locked to desired frequency; while(LPC_SC->PLL0STAT &(1<<26)==0x00);

/////CONNECT PLL0///// { pc.printf("BREAK6\n"); LPC_SC->PLL0CON|=(1<<1); LPC_SC->PLL0FEED =0xAA; LPC_SC->PLL0FEED =0x55; while(LPC_SC->PLL0STAT &(1<<25)==0x00); } }

///PRINTING D VALUE//// int main() { initclock(); wait(1); pc.printf("HI\n"); pc.printf("PLL0CON =0x%08X\n",LPC_SC->PLL0CON); pc.printf("PLL0STAT=0x%08X\n",LPC_SC->PLL0STAT); pc.printf("PLLCLK =0x%08X\n",LPC_SC->CCLKCFG); int value=LPC_SC->PLL0STAT&0x7FFF; pc.printf("value %d\n",value); } <</code>>t i am sure is it working at 96mhz and if try to print the msg that is insidte the initclock i dont getting that and i oly get the values that is in main function,

posted by Ashok K 28 May 2014

I can see your code now, you changed the clocksettings, thus call SystemCoreClockUpdate(), which updates SystemCoreClock variable. Print that value to find out what's the core clock

posted by Martin Kojtal 28 May 2014

hi martin ,if i execute the pll program i get 96 Mhz wen systemcoreclock is dispalyed.. i tried changing the clockdiv(CCLKCFG) so as to update(72Mhz) and executed i get junk values wen printed.. can i know wht is der problem with my code....pls help <<code>>

int main() { initclock();

pc.printf("HI\n");

pc.printf("PLL0CON =0x%08X\n",LPC_SC->PLL0CON);

pc.printf("PLL0STAT=0x%08X\n",LPC_SC->PLL0STAT);

pc.printf("PLLCLK =0x%08X\n",LPC_SC->CCLKCFG);

int value=LPC_SC->PLL0STAT&0x7FFF;

pc.printf("value %d\n",value);

SystemCoreClockUpdate();

pc.printf("%d",SystemCoreClock);

} <</code>>

the initclock( function is attached above);

posted by Ashok K 29 May 2014

Assigned to Ashok K 9 years, 11 months ago.

This means that the question has been accepted and is being worked on.