Module 2 ECEN 5803 Project 1 Submitted by 1. Rahul Yamasani 2. Srivishnuj Alvakonda
Dependencies: MMA8451Q TSI mbed
Fork of FRDM_MMA8451Q by
Revision 8:3246b1db17ce, committed 2017-10-12
- Comitter:
- sral4054
- Date:
- Thu Oct 12 03:24:10 2017 +0000
- Parent:
- 7:70775be9f474
- Commit message:
- Module 2 ECEN 5803 Project 1; ; Submitted by; 1. Rahul Yamasani; 2. Srivishnuj Alvakonda;
Changed in this revision
TSI.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 70775be9f474 -r 3246b1db17ce TSI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TSI.lib Thu Oct 12 03:24:10 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/TSI/#1a60ef257879
diff -r 70775be9f474 -r 3246b1db17ce main.cpp --- a/main.cpp Tue Feb 19 23:46:45 2013 +0000 +++ b/main.cpp Thu Oct 12 03:24:10 2017 +0000 @@ -1,18 +1,50 @@ #include "mbed.h" #include "MMA8451Q.h" +#include "TSISensor.h" + +Timer timer; +Timer timer2; +Serial pc(USBTX, USBRX); #define MMA8451_I2C_ADDRESS (0x1d<<1) - -int main(void) { + +int main(void) +{ MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS); PwmOut rled(LED_RED); PwmOut gled(LED_GREEN); PwmOut bled(LED_BLUE); - - while (true) { + TSISensor tsi; + timer.start(); + timer2.start(); + double timer_read = 0.0; + double timer_read2 = 0.0; + + int i = 0; + while (true) + { + timer.reset(); rled = 1.0 - abs(acc.getAccX()); gled = 1.0 - abs(acc.getAccY()); bled = 1.0 - abs(acc.getAccZ()); + gled = 1.0 - tsi.readPercentage(); + timer_read += timer.read(); wait(0.1); - } + + i++; + + if (i==100) + { + timer_read2 = timer2.read(); + pc.printf("\n\rCPU Load Execution time: %f\n\r", timer_read); + pc.printf("Total Program Execution time: %f\n\r\n\r", timer_read2); + + double processor_load = double(timer_read/timer_read2); + processor_load *= 100; + pc.printf("RESULT\n\r"); + pc.printf("Processor load in percentage of CPU cycles %f\n\r", processor_load); + pc.printf("CPU available percentage is %f\n\r", 100.0 - processor_load); + } + } + }