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 //******************************************************** 00003 //** ARM Cortex M7 MCU ****** 00004 //** ST Nucleo-144 Stm32F746 and Stm32F767 MCU ****** 00005 //** Newton's approximation - Benchmark based on ****** 00006 //** Steve Curd Adruino IDE code ****** 00007 //** Jovan Ivković - 2017. ****** 00008 //** JovanEps (jovan.eps@gmail.com). ****** 00009 //******************************************************** 00010 00011 DigitalOut myled(LED1); 00012 //DigitalOut PD13(PA_5); //introduce D13 pin-out 00013 DigitalIn PD8(PF_12); //introduce D8 *-Clear port 00014 Serial pc(USBTX, USBRX); 00015 Timer timer; 00016 00017 #define ITERATIONS 10000000L // number of iterations 100k-10M 00018 #define FFLASH 1000000 // blink LED every 100k-1M iterations 00019 00020 //#include <TM1638.h> // include the display library 00021 00022 // TM1638 module(DIO, CLK, STB0) 00023 //TM1638 module(8, 9, 7); 00024 00025 //********************************* 00026 //** MAIN block ** 00027 //********************************* 00028 int main() 00029 { 00030 while(true) { 00031 unsigned long start, ttime; 00032 unsigned long niter = ITERATIONS; 00033 int LEDcounter = 0; 00034 bool alternate = false; 00035 long i, count = 0; 00036 double x = 1.0; 00037 double temp, pi = 1.0; 00038 00039 pc.printf(" \n Beginning %d",niter ); 00040 pc.printf(" \n iterations..."); 00041 pc.printf("\n"); 00042 00043 timer.start(); 00044 start = timer.read_ms(); 00045 00046 for ( i = 2; i < niter; i++) { 00047 x *= -1.0; 00048 pi += x / (2.0f * (float) i - 1.0f); 00049 // /* 00050 if (LEDcounter++ > FFLASH) { 00051 LEDcounter = 0; 00052 if (alternate) { 00053 myled = 1; 00054 alternate = false; 00055 } else { 00056 myled = 0; 00057 alternate = true; 00058 } 00059 temp = (float) 40000000.0 * pi; 00060 00061 //module.setDisplayToDecNumber( temp, 0x80); 00062 } 00063 //*/ 00064 } 00065 ttime = timer.read_ms() - start; 00066 00067 pi = (double) pi * 4.0; 00068 00069 pc.printf("# of trials = %d \n", niter); 00070 pc.printf("\n\n"); 00071 pc.printf("Estimate of pi = %6.10f 10 \n" , pi); 00072 pc.printf("Time: %d ms \n", ttime); 00073 printf("state: %d \n", alternate); 00074 00075 timer.stop(); 00076 wait(1); 00077 } 00078 }
Generated on Fri Jul 22 2022 22:06:17 by
1.7.2