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 CMSIS_DSP_5
Diff: main.cpp
- Revision:
- 1:bdbd76df2103
- Parent:
- 0:0d5a524c7d25
- Child:
- 2:69827542e976
--- a/main.cpp Mon Oct 08 12:27:03 2018 +0000
+++ b/main.cpp Mon Oct 08 17:12:37 2018 +0000
@@ -3,17 +3,50 @@
#include "arm_math.h"
//#include "math.h"
+float datosf[500];
DigitalOut myled(LED1);
Timer timer;
int16_t dato;
+int32_t producto;
+float productof;
+int64_t sumatorio=0;
+float sumatoriof=0.0;
+float final;
+
+void initFloat();
+void Calculo1();
+void Calculo1Float();
+void Calculo2();
+void Calculo3();
int main()
{
- int32_t producto;
- int64_t sumatorio=0;
- float final;
+
+ initFloat();
+ Calculo1();
+ Calculo1Float();
+ Calculo2();
+ Calculo3();
+
+
+
+ //int16_t resultado;
+ //arm_rms_q15(datos,500, &resultado);
+}
+
+void initFloat()
+{
+ for (int n=0; n<500; n++) {
+ datosf[n]=datos[n];
+ }
+}
+
+void Calculo1()
+{
+ sumatorio=0;
+ timer.reset();
timer.start();
for (int n=0; n<500; n++) {
producto=datos[n]*datos[n];
@@ -21,9 +54,30 @@
}
timer.stop();
final=sumatorio;
+ printf("****Calculo 1****\n");
printf("%f ",final);
printf("tiempo %d\n",timer.read_us());
-
+
+}
+
+void Calculo1Float()
+{
+ sumatoriof=0;
+ timer.reset();
+ timer.start();
+ for (int n=0; n<500; n++) {
+ productof=datosf[n]*datosf[n];
+ sumatoriof+=productof;
+ }
+ timer.stop();
+ final=sumatoriof;
+ printf("****Calculo 1 Float****\n");
+ printf("%f ",final);
+ printf("tiempo %d\n",timer.read_us());
+}
+
+void Calculo2()
+{
sumatorio=0;
timer.reset();
timer.start();
@@ -34,19 +88,22 @@
}
timer.stop();
final=sumatorio;
+ printf("****Calculo 2****\n");
printf("%f ",final);
printf("tiempo %d\n",timer.read_us());
+}
+
+void Calculo3()
+{
timer.reset();
timer.start();
arm_dot_prod_q15(datos,datos,500,&sumatorio);
timer.stop();
final=sumatorio;
+ printf("****Calculo 3****\n");
printf("%f",final);
printf("tiempo %d\n",timer.read_us());
- //int16_t resultado;
- //arm_rms_q15(datos,500, &resultado);
-
}