Jump to content
Simao

I can´t undertand SysCtlClockGet() behaviour

Recommended Posts

     Hi there, I would really appreciate any  help here. Assuming ClockVal defined as

 

unsigned long Clockval=0

     After executing this 2 lines of code...    
     

SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
 
ClockVal = SysCtlClockGet();


     What should be the correct value of Clockval? A friend of mine reported 40,000.000  meaning 40 Mhz using IAR, in my case running Keil I get 3,200000 or 3.2 Mhz, does abybody have a clue for this weird value??

Thanks a lot in advance

 

Simao

 

 

P.S.  1) We both use Stellaris LM4F120 LaunchPad Evaluation Kit

 

P.S.  2) It´s my first post so please bear with me if it´s not formaly correct.

Share this post


Link to post
Share on other sites

@@Simao

 

Following will set the Stellaris Launchpad at 80Mhz

SysCtlClockSet(	SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL |	\
					SYSCTL_OSC_MAIN   | SYSCTL_XTAL_16MHZ);

What this means is - You are instructing the PLL to run to 400Mhz using the 16Mhz as input to it. The PLL is then divided by 2 internally in hardware, and then 2.5

400/2/2.5 = 80

SysCtlClockGet() will give you 80000000Hz.

SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
 
ClockVal = SysCtlClockGet();

400/2/5 = 40Mhz

 

Explained here too.

Share this post


Link to post
Share on other sites

     Acctually it worked already, my concern is about the value I get when I call SysCtlClockGet(), I guess I have to dig into KEIL help files to know what is happening but freq is OK.

     Thanks again.

 

Simao

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×