Anthony Mukuka Mwila
/
InterruptCounterTimertestUnit
Testing of counter using interrupts
main.cpp
- Committer:
- Amwila
- Date:
- 2017-11-28
- Revision:
- 3:369add4c5412
- Parent:
- 2:4772acaa0e64
File content as of revision 3:369add4c5412:
#include "mbed.h" // Interrupt Initialisation InterruptIn BLM_CHANNEL_A(PG_5); //Variable Initialisation volatile int A_count = 0 , CountFlag = 0 ; float FinalCountTime = 0 ; Timer Count_Timer ; // Interrupt Counter Increment Function void IncA() { A_count ++ ; if(A_count == 1){ Count_Timer.start(); } if(A_count == 10000){ // 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 ; } } int main() { printf(" The Program Is Running "); while (true) { // 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); } }