Thursday, 23 February 2017

Write an application to and demonstrate the change in BeagleBoard( ARM Cortex A8) /CPU frequency or square wave of programmable frequency.



Following is the code to demonstrate change in  Beagle Bone Board CPU Frequency:

#Code (assignment.py):

import os


print "Current CPU Information"
os.system("cpufreq-info")

print "\n"

#300MHz
print "Changing current frequency to: 300MHz"
os.system("cpufreq-set -f 300Mhz")
os.system("python fact.py")

print "\n"

#600MHz
print "Changing current frequency to: 600MHz"
os.system("cpufreq-set -f 600Mhz")
#os.system("cpufreq-info")
os.system("python fact.py")

print "\n"

#800MHz
print "Changing current frequency to: 800MHz"
os.system("cpufreq-set -f 800Mhz")
os.system("python fact.py")

print "\n"

#1000MHz
print "Changing current frequency to: 1000MHz"
os.system("cpufreq-set -f 1000Mhz")
os.system("python fact.py")

print "\n"

os.system("cpufreq-set -f 300Mhz")   #Restoring back original frequency



#fact.py:

import sys,time
def Factorial():
    n = 100
    fact=1
    for i in range(1,n+1):
       fact=fact*i

start_time=time.time()
Factorial()
print "Time taken in fact.py: %s seconds" % (time.time()-start_time)

#Output:

root@beaglebone:~# python assignment.py
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
  driver: generic_cpu0
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 300 us.
  hardware limits: 300 MHz - 1000 MHz
  available frequency steps: 300 MHz, 600 MHz, 800 MHz, 1000 MHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance
  current policy: frequency should be within 300 MHz and 1000 MHz.
                  The governor "userspace" may decide which speed to use
                  within this range.
  current CPU frequency is 300 MHz (asserted by call to hardware).
  cpufreq stats: 300 MHz:68.71%, 600 MHz:3.54%, 800 MHz:25.30%, 1000 MHz:2.45%  (33)

Current frequency: 300MHz
Time taken in fact.py: 0.000475883483887 seconds


Current frequency: 600MHz
Time taken in fact.py: 0.000253200531006 seconds


Current frequency: 800MHz
Time taken in fact.py: 0.000197887420654 seconds


Current frequency: 1000MHz
Time taken in fact.py: 0.000165939331055 seconds

No comments:

Post a Comment