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
clock.cpp
- Committer:
- liangzhen
- Date:
- 2014-07-17
- Revision:
- 3:e1a6e12233dd
- Parent:
- 0:84a8bcfbdec9
File content as of revision 3:e1a6e12233dd:
#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;
}
