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.
Dependencies: DDRO_Farrari mbed
Fork of DDRO_Farrari by
Diff: clock.cpp
- Revision:
- 0:84a8bcfbdec9
diff -r 000000000000 -r 84a8bcfbdec9 clock.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/clock.cpp Mon Oct 07 22:58:19 2013 +0000
@@ -0,0 +1,26 @@
+#include "clock.h"
+
+float ext_freq(DigitalIn* clk_pin)
+{
+ bool last = false;
+ unsigned int count = 0;
+
+ Timer t;
+ t.start();
+ for(int i=0; i<100000; i++){
+ bool clkval = *clk_pin;
+ if(clkval && !last){
+ count++;
+ }
+ last = clkval;
+ }
+ float time = t.read();
+ t.stop();
+ if(count < 1000){
+ dual_printf("Clk read inaccurate");
+ pc.printf("Clk count %d\r\n", count);
+ }
+ //pc.printf("T: %f\r\nC: %i\r\n", time, count);
+
+ return count / time;
+}
\ No newline at end of file
