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.
main.cpp
00001 #include "mbed.h" 00002 #include "FastIO.h" 00003 00004 //DigitalOut bitstream(p8); 00005 FastOut<p8> bitstream; 00006 DigitalOut myled(LED1); 00007 00008 Serial pc(USBTX, USBRX); // tx, rx 00009 Timer timer; 00010 00011 #define LOOP 1000000 00012 00013 int main() { 00014 int data[42]; 00015 data[ 0] = 0; 00016 data[ 1] = 1; 00017 data[ 2] = 0; 00018 data[ 3] = 0; 00019 data[ 4] = 1; 00020 data[ 5] = 1; 00021 data[ 6] = 0; 00022 data[ 7] = 0; 00023 data[ 8] = 0; 00024 data[ 9] = 1; 00025 data[10] = 1; 00026 data[11] = 1; 00027 data[12] = 0; 00028 data[13] = 0; 00029 data[14] = 0; 00030 data[15] = 0; 00031 data[16] = 1; 00032 data[17] = 1; 00033 data[18] = 1; 00034 data[19] = 1; 00035 data[20] = 0; 00036 data[21] = 0; 00037 data[22] = 0; 00038 data[23] = 0; 00039 data[24] = 0; 00040 data[25] = 1; 00041 data[26] = 1; 00042 data[27] = 1; 00043 data[28] = 1; 00044 data[29] = 1; 00045 data[30] = 0; 00046 data[31] = 0; 00047 data[32] = 0; 00048 data[33] = 0; 00049 data[34] = 0; 00050 data[35] = 0; 00051 data[36] = 1; 00052 data[37] = 1; 00053 data[38] = 1; 00054 data[39] = 1; 00055 data[40] = 1; 00056 data[41] = 1; 00057 int index = 0; 00058 int dummy; 00059 int iter_incr = 1; 00060 float duration; 00061 pc.baud(115200); 00062 pc.printf("Start\n"); 00063 timer.reset(); 00064 timer.start(); 00065 loop: 00066 for (int i = 0; i < LOOP; i+=iter_incr) { 00067 bitstream = data[index]; 00068 index = (index+1)%42; 00069 /* Begin of useless calculation to force 1 MHz runtime */ 00070 dummy = 3; 00071 for (int j = 0; j <51; j++) { 00072 dummy+=dummy; 00073 } 00074 /* End of useless calculation to force 1 MHz runtime */ 00075 } 00076 timer.stop(); 00077 duration = timer.read(); 00078 pc.printf("Loop took %f seconds, %g per iteration\n",duration,duration/LOOP); 00079 /* After testing the speed of the loop during 1 second, now continu to run it forever. */ 00080 iter_incr = 0; 00081 goto loop; 00082 }
Generated on Sat Jul 16 2022 23:01:50 by
1.7.2