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:
- 2:69827542e976
- Parent:
- 1:bdbd76df2103
- Child:
- 3:44b632ea58aa
- Child:
- 6:2a9b1cc25f1b
--- a/main.cpp Mon Oct 08 17:12:37 2018 +0000
+++ b/main.cpp Wed Oct 17 17:00:32 2018 +0000
@@ -1,109 +1,25 @@
#include "mbed.h"
#include "datos.h"
-#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;
+float resultado;
-void initFloat();
-void Calculo1();
-void Calculo1Float();
-void Calculo2();
-void Calculo3();
+float calcularRMS(int16_t *datos, int longitud);
+
int main()
{
- 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];
- sumatorio+=producto;
- }
+ resultado=calcularRMS(datos, 500);
timer.stop();
- final=sumatorio;
- printf("****Calculo 1****\n");
- printf("%f ",final);
- printf("tiempo %d\n",timer.read_us());
+ printf("****El valor Vrms es %f ****\n",resultado);
}
-void Calculo1Float()
+float calcularRMS(int16_t *datos, int longitud)
{
- 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());
+ return 0.0;
}
-void Calculo2()
-{
- sumatorio=0;
- timer.reset();
- timer.start();
- for (int n=0; n<500; n++) {
- dato=datos[n];
- producto=dato*dato;
- sumatorio+=producto;
- }
- 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());
-
-}