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: mbed
Revision 0:1b13e5949a49, committed 2019-08-02
- Comitter:
- csoulen
- Date:
- Fri Aug 02 18:18:15 2019 +0000
- Commit message:
- Code used to read a SN74LV8451 frequency counter. Use this to test if the counter is working appropriately;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Aug 02 18:18:15 2019 +0000
@@ -0,0 +1,110 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX);
+DigitalOut clear_data(p21);
+BusIn data(p29, p28, p27, p26, p25, p24, p23, p22);
+DigitalOut CSAL(p16);
+DigitalOut CSAU(p17);
+DigitalOut CSBL(p18);
+DigitalOut CSBU(p19);
+DigitalOut store_data(p20);
+Timer t;
+
+
+
+
+int mean_number = 1000;
+float time_stop = 10; //in ms
+float freq_mean = 0;
+
+
+
+int main()
+{
+ float frequency[mean_number];
+ float time_elapsed[mean_number];
+ //int total_counts[mean_number];
+ int total_counts;
+ //unsigned int data_store[4][mean_number];
+ unsigned int data_store[2];
+ store_data.write(1);
+ clear_data.write(1);
+ CSAL.write(1);
+ CSAU.write(1);
+ CSBL.write(1);
+ CSBU.write(1);
+
+ while(1)
+ {
+ clear_data.write(0);
+ store_data.write(0);
+ clear_data.write(1);
+
+ wait_ms(time_stop);
+
+ store_data.write(1);
+
+ wait_us(10);
+
+ CSAL.write(0);
+ data_store[0] = data;
+ CSAL.write(1);
+ pc.printf("%u ",data_store[0]);
+ wait_us(10);
+
+ CSAU.write(0);
+ data_store[1] = data;
+ CSAU.write(1);
+ pc.printf("%u ",data_store[1]);
+
+
+ data_store[1] = data_store[1]<<8;
+ total_counts = data_store[1]| data_store[0];
+ pc.printf("total counts: %i \r\n",total_counts);
+
+
+ }
+
+ /*
+ for (int n = 0; n<mean_number; n++)
+ {
+ clear_data.write(0);
+ store_data.write(0);
+ clear_data.write(1);
+
+ wait_ms(time_stop);
+
+ store_data.write(1);
+
+ wait_us(10);
+
+ CSAL.write(0);
+ data_store[0][n] = data;
+ CSAL.write(1);
+
+ wait_us(10);
+
+ CSAU.write(0);
+ data_store[1][n] = data;
+ CSAU.write(1);
+
+ }
+
+ for (int n = 0; n<mean_number; n++)
+ {
+
+ data_store[3][n] = data_store[3][n]<<24;
+ data_store[2][n] = data_store[2][n]<<16;
+ data_store[1][n] = data_store[1][n]<<8;
+
+ total_counts[n] = data_store[1][n]| data_store[0][n];
+ frequency[n] = total_counts[n]/(time_stop/100);
+ pc.printf("%u %u total counts: %i \r\n",data_store[0][n],data_store[1][n]>>8,total_counts[n]);
+
+
+ }
+ */
+
+
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Aug 02 18:18:15 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file