Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 3:369add4c5412, committed 2017-11-28
- Comitter:
- Amwila
- Date:
- Tue Nov 28 22:11:50 2017 +0000
- Parent:
- 2:4772acaa0e64
- Commit message:
- Final;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Oct 03 19:52:03 2017 +0000
+++ b/main.cpp Tue Nov 28 22:11:50 2017 +0000
@@ -4,7 +4,8 @@
InterruptIn BLM_CHANNEL_A(PG_5);
//Variable Initialisation
-int A_count = 0 , FinalCountTime = 0 , CountFlag = 0 ;
+volatile int A_count = 0 , CountFlag = 0 ;
+float FinalCountTime = 0 ;
Timer Count_Timer ;
// Interrupt Counter Increment Function
@@ -14,11 +15,27 @@
if(A_count == 1){
- CountFlag = 1;
+ Count_Timer.start();
}
if(A_count == 10000){
- CountFlag = 2;
+ // Stopping timer at 10000 Counts
+ Count_Timer.stop();
+
+ // Reading Counter Time
+ FinalCountTime = Count_Timer.read();
+
+ // Outputting Final count to Terminal
+ printf(" %f is the Count established \n ",FinalCountTime);
+
+ // Resetting Timer
+ Count_Timer.reset();
+
+ //Setting Counter and CountFlag to 0
+ A_count = 0;
+ CountFlag = 0;
+ FinalCountTime = 0 ;
+
}
}
@@ -31,32 +48,11 @@
{ printf(" The Program Is Running ");
while (true) {
-
- if ( CountFlag == 1)
- {
- // Starting timer at 1 Count
- Count_Timer.start();
- CountFlag = 0 ;
- }
- if (CountFlag == 2 )
- {
- // Stopping timer at 10000 Counts
- Count_Timer.stop();
-
- // Reading Counter Time
- FinalCountTime = Count_Timer.read_us();
-
- // Outputting Final count to Terminal
- printf("Final Count Time for 10000 counts is : %d ",FinalCountTime);
-
- //Setting Counter and CountFlag to 0
- A_count = 0;
- CountFlag = 0;
- }
-
+
// Calling of the increment function on the rising edge of a pulse
BLM_CHANNEL_A.rise(&IncA);
-
+
+ //printf(" The System Core Clock frequency is %d Hz ",SystemCoreClock);
}
}