Grupo AAE / Mbed 2 deprecated P2_E4

Dependencies:   mbed

Revision:
0:2b6bac81f08c
diff -r 000000000000 -r 2b6bac81f08c main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Oct 15 10:04:42 2019 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+#include "datos.h"
+#include "math.h"
+
+Timer timer;
+float resultado;
+int tiempo;
+
+float calcularRMS(int16_t *datos, int longitud);
+
+
+int main()
+{
+ 
+    timer.reset();
+    timer.start();
+    resultado=calcularRMS(datos, 500);
+    timer.stop();
+    printf("****El valor Vrms es %f calculado en %d us ****\n",resultado,timer.read_us());
+
+}
+
+float calcularRMS(int16_t *datos, int longitud)
+{
+    int64_t sumatorio=0;
+    for (int i=0; i< longitud;i++)
+    {
+        sumatorio =+ datos[i]*datos[i];
+        }
+    
+    float cte = 0.0001007080078125;
+    int resultado = cte * sqrt((float)sumatorio/longitud);
+    return resultado;
+}
+