Liangzhen Lai / Mbed 2 deprecated DDRO_software

Dependencies:   mbed

Revision:
4:fc56fa8aa794
Parent:
3:764ccaf29ce9
Child:
5:0a3fb48e39a3
diff -r 764ccaf29ce9 -r fc56fa8aa794 main.cpp
--- a/main.cpp	Thu Sep 20 23:45:05 2012 +0000
+++ b/main.cpp	Sat Sep 29 19:22:38 2012 +0000
@@ -4,6 +4,8 @@
 #include "JTAG.h"
 using namespace std;
 
+//#define FILE_OUTPUT
+
 DigitalOut RESET (p21);
 
 Serial s(USBTX, USBRX);
@@ -15,35 +17,71 @@
     double voltage = 1;
     PLL clk;
     JTAG jtag;
-    int* ro_readings = new int [64];
+    int* ro_readings = new int [70];
+#ifdef FILE_OUTPUT
     FILE *outFile = fopen("/local/test.out", "a");
-    for (int i=0; i<7; i++) {
+#endif
+    for (int i=0; i<1; i++) {
         voltage = 1 - 0.05*i;
         powerReset();
         powerUp(voltage);
+#ifdef FILE_OUTPUT
         fprintf(outFile, "Voltage: %f\n", voltage);
+#endif
         RESET = 0;
         wait_us(10);
         RESET = 1;
-        master_write();
-        master_read(ro_readings);
-
-        for (int ii=0; ii<64; ii++) {
-            fprintf(outFile, "RO %d %d\n", ii, ro_readings[ii]);
+        for(int iii=0; iii<1; iii++) {
+            master_write();
+            master_read(ro_readings);
+            for (int ii=0; ii<64; ii++) {
+#ifdef FILE_OUTPUT
+                fprintf(outFile, "RO %d %d\n", ii, ro_readings[ii]);
+#endif
+                s.printf("RO %d %d\n", ii, ro_readings[ii]);
+            }
+#ifdef FILE_OUTPUT
+            fprintf(outFile, "CORE %X\nSRAM %X\n", ro_readings[64],ro_readings[65]);
+#endif
+            double core_meas = 3.3*ro_readings[64]/0x10000;
+            double sram_meas = 3.3*ro_readings[65]/0x10000;
+            s.printf("CORE %X\nSRAM %X\n", ro_readings[64],ro_readings[65]);
+            s.printf("CORE %f\nSRAM %f\n", core_meas, sram_meas);
+            double rvtp_meas = 3.3*ro_readings[66]/0x10000;
+            double hvtp_meas = 3.3*ro_readings[67]/0x10000;
+            double rvtn_meas = 3.3*ro_readings[68]/0x10000;
+            double hvtn_meas = 3.3*ro_readings[69]/0x10000;
+#ifdef FILE_OUTPUT
+            fprintf(outFile, "RVTP %X\nHVTP %X\nRVTN %X\nHVTN %X\n", ro_readings[66],ro_readings[67], ro_readings[68],ro_readings[69]);
+            fprintf(outFile, "RVTP %f\nHVTP %f\nRVTN %f\nHVTN %f\n", rvtp_meas, hvtp_meas, rvtn_meas, hvtn_meas);
+#endif
         }
         int fmax;
         int lower = 51;
         int higher = 199;
         int frequency = (lower+higher)/2;
-        clk.setPLL(frequency))
+        clk.setPLL(frequency);
+        clk.setPLL(frequency);
         RESET = 0;
         wait_us(10);
         RESET = 1;
-        while (higher - lower >1) {
-        if(jtag.JTAG_test()) {
+
+        // power characterization
+        frequency = 151;
+        clk.setPLL(frequency);
+        clk.setPLL(frequency);
+        RESET = 0;
+        wait_us(10);
+        RESET = 1;
+        //jtag.JTAG_test();
+        /*
+        while (higher - lower >100) {
+            s.printf("testing %d\n", frequency);
+            if(jtag.JTAG_test()) {
                 lower = frequency;
                 frequency = (lower+higher)/2;
                 clk.setPLL(frequency);
+                clk.setPLL(frequency);
                 RESET = 0;
                 wait_us(10);
                 RESET = 1;
@@ -51,15 +89,22 @@
                 higher = frequency;
                 frequency = (lower+higher)/2;
                 clk.setPLL(frequency);
+                clk.setPLL(frequency);
                 RESET = 0;
                 wait_us(10);
                 RESET = 1;
             }
         }
+        */
+#ifdef FILE_OUTPUT
         fprintf(outFile, "fmax %d\n", lower*5);
+#endif
+        s.printf("fmax %d\n", lower*5);
         powerDown();
     }
+#ifdef FILE_OUTPUT
     fclose(outFile);
+#endif
     s.printf("DDRO_software ends.\r\n");
     while(1) {
         finish_flag = !finish_flag;