Write an application to and demonstrate the change in BeagleBoard/ ARM Cortex
A5 /Microprocessor /CPU frequency or square wave of programmable frequency
#include<stdlib.h> //System() Function
#include<signal.h> //signal Handler for CNTR-C
#include<iostream> //cout , cin
#include<string> //string
#include<conio.h>
using namespace std;
void delay(int num);
int main()
{
int option;
string frq;
string command;
while(1)
{
cout << "\n1. Press 1 to set the Beagle Board CPU Frequency\n";
cout << "2. Press 2 to get the current CPU Frequency\n";
cout << "3. Press 3 or CNTR-Z to exit\n";
cin > > option;
switch(option)
{
case 1:
cout << "Please Enter the frequency in range 100-1000 (MHz)\n";
cin > > frq;
command="cpufreq-set -f "+frq+"MHz";
if(system(command.c_str()))
cout << "\nCannot Set the Frequency. Make sure logged in as ROOT\n";
case 2:
while(!kbhit())
{
cout << "Press any key to go Back in main menu \n";
system("cpufreq-info | tail -2");
delay(50000);
}
break;
case 3:
exit(0);
}
}
}
void delay(int num)
{
int i,j;
for(i=0; i < num;i++)
for(j=0; j < 1275;j++);
}
OUTPUT:-
root@beaglebone:/home/debian# g++ -o cpu cpu.cpp
Cannot create temporary file in ./: Read-only file system
Aborted
root@beaglebone:/home/debian# ./cpu
1. Press 1 to set the Beagle Board CPU Frequency
2. Press 2 to get the current CPU Frequency
3. Press 3 or CNTR-Z to exit
2
Press CNTR+C to Back in main menu
current CPU frequency is 300 MHz (asserted by call to hardware).
cpufreq stats: 300 MHz:70.37%, 600 MHz:16.56%, 800 MHz:0.09%, 1000 MHz:12.98%)
Press CNTR+C to Back in main menu
current CPU frequency is 300 MHz (asserted by call to hardware).
cpufreq stats: 300 MHz:70.40%, 600 MHz:16.55%, 800 MHz:0.09%, 1000 MHz:12.96%)
^C
1. Press 1 to set the Beagle Board CPU Frequency
2. Press 2 to get the current CPU Frequency
3. Press 3 or CNTR-Z to exit
1
Please Enter the frequency in range 100-1000 (MHz)
600
Press CNTR+C to Back in main menu
current CPU frequency is 600 MHz (asserted by call to hardware).
cpufreq stats: 300 MHz:70.62%, 600 MHz:16.42%, 800 MHz:0.09%, 1000 MHz:12.87%)
Press CNTR+C to Back in main menu
current CPU frequency is 600 MHz (asserted by call to hardware).
cpufreq stats: 300 MHz:70.58%, 600 MHz:16.47%, 800 MHz:0.09%, 1000 MHz:12.86%)
^C
1. Press 1 to set the Beagle Board CPU Frequency
2. Press 2 to get the current CPU Frequency
3. Press 3 or CNTR-Z to exit
3
root@beaglebone:/home/debian# ^C
root@beaglebone:/home/debian#
No comments:
Post a Comment