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.
Revision 7:b98d752b7b95, committed 2012-10-02
- Comitter:
- liangzhen
- Date:
- Tue Oct 02 23:53:32 2012 +0000
- Parent:
- 6:a27c0fd4f210
- Commit message:
- with all features
Changed in this revision
--- a/JTAG.cpp Tue Oct 02 01:16:03 2012 +0000
+++ b/JTAG.cpp Tue Oct 02 23:53:32 2012 +0000
@@ -306,54 +306,37 @@
bool JTAG::JTAG_test(void)
{
+
+ //for FFT test
unsigned int address = 0x44000008;
unsigned int value = 0x00000001;
JTAG_RESET = 0;
wait_us(100);
JTAG_RESET = 1;
wait_us(100);
+
+ //readID();
DAP_enable();
+
loadProgram();
+ address = 0x44000008;
value = 0x00000001;
- address = 0x44000004;
- for(int i=0; i<10000; i++) {
- writeMemory(address, value);
- wait_us(1);
- }
- /*
- //for FFT test
- unsigned int address = 0x44000008;
- unsigned int value = 0x00000001;
- JTAG_RESET = 0;
- wait_us(100);
- JTAG_RESET = 1;
- wait_us(100);
-
- //readID();
- DAP_enable();
-
- loadProgram();
+ writeMemory(address, value);
- address = 0x44000008;
- value = 0x00000001;
- writeMemory(address, value);
-
- address = 0x44000004;
- writeMemory(address, value);
- wait(2);
- bool if_match = true;
- for(int i=0; i<256; i++) {
- address = 0x60000100;
- address += i*0x4;
- value = readMemory(address);
- if (expected_result[i]!=value) {
- if_match = false;
- }
+ address = 0x44000004;
+ writeMemory(address, value);
+ wait(0.5);
+ bool if_match = true;
+ for(int i=0; i<256; i++) {
+ address = 0x60000100;
+ address += i*0x4;
+ value = readMemory(address);
+ if (expected_result[i]!=value) {
+ if_match = false;
}
- //if (if_match) { pc_jtag.printf("FFT match\n"); }
- return if_match;
- */
+ }
+ return if_match;
}
void JTAG::loadProgram()
--- a/main.cpp Tue Oct 02 01:16:03 2012 +0000
+++ b/main.cpp Tue Oct 02 23:53:32 2012 +0000
@@ -4,7 +4,7 @@
#include "JTAG.h"
using namespace std;
-//#define FILE_OUTPUT
+#define FILE_OUTPUT
DigitalOut RESET (p21);
@@ -40,12 +40,12 @@
address = 0x44000004;
jtag.writeMemory(address, value);
//core is running......
-
-
+
+
int* ro_readings = new int [70]; //0-63: Oscillator (DDRO), 64-65: SRAM/Core Power, 66-69: Leakage
master_write();
master_read(ro_readings);
-
+
if( some GPIO != 0) {powerDown();}
}
*/
@@ -56,7 +56,7 @@
double voltage = 1;
PLL clk;
JTAG jtag;
- int* ro_readings = new int [70];
+ int* ro_readings = new int [68];
#ifdef FILE_OUTPUT
FILE *outFile = fopen("/local/test.out", "a");
#endif
@@ -77,22 +77,16 @@
#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);
+ fprintf(outFile, "CORE %f\nSRAM %f\n", core_meas,sram_meas);
+#endif
+ double hvtp_meas = 1.8*0.33/ro_readings[66]/0.001;
+ double hvtn_meas = 1.5*0.33/ro_readings[67]/0.001;
+#ifdef FILE_OUTPUT
+ fprintf(outFile, "HVTP %f\nHVTN %f\n", hvtp_meas, hvtn_meas);
#endif
}
int fmax;
@@ -105,16 +99,7 @@
wait_us(10);
RESET = 1;
- // power characterization
- frequency = 151;
- clk.setPLL(frequency);
- clk.setPLL(frequency);
- RESET = 0;
- wait_us(10);
- RESET = 1;
- //jtag.JTAG_test();
- /*
- while (higher - lower >30) {
+ while (higher - lower >1) {
s.printf("testing %d\n", frequency);
if(jtag.JTAG_test()) {
lower = frequency;
@@ -134,12 +119,11 @@
RESET = 1;
}
}
- */
+
#ifdef FILE_OUTPUT
fprintf(outFile, "fmax %d\n", lower*5);
#endif
- s.printf("fmax %d\n", lower*5);
powerDown();
}
#ifdef FILE_OUTPUT
--- a/master_i2c.cpp Tue Oct 02 01:16:03 2012 +0000
+++ b/master_i2c.cpp Tue Oct 02 23:53:32 2012 +0000
@@ -95,13 +95,13 @@
void master_read(int* ro_reading)
{
char* data_read;
- data_read = new char [64*5+12];
- for(int i=0; i<64*5+12; i++) {
+ data_read = new char [64*5+8];
+ for(int i=0; i<64*5+8; i++) {
data_read[i]=(char)47;
}
while(data_read[0]==47) {
- wait(18);
- master.read(SLAVEADDR|1, data_read, 64*5+12, true);
+ wait(10);
+ master.read(SLAVEADDR|1, data_read, 64*5+8, true);
}
for(int i=0; i<64; i++) {
int out = 0;
@@ -118,8 +118,6 @@
}
ro_reading[64] = data_read[64*5]+data_read[64*5+1]*0x100;
ro_reading[65] = data_read[64*5+2]+data_read[64*5+3]*0x100;
- ro_reading[66] = data_read[64*5+4]+data_read[64*5+5]*0x100; //RVTP
- ro_reading[67] = data_read[64*5+6]+data_read[64*5+7]*0x100; //HVTP
- ro_reading[68] = data_read[64*5+8]+data_read[64*5+9]*0x100; //RVTN
- ro_reading[69] = data_read[64*5+10]+data_read[64*5+11]*0x100; //HVTN
+ ro_reading[66] = data_read[64*5+4]+data_read[64*5+5]*0x100; //HVTP
+ ro_reading[67] = data_read[64*5+6]+data_read[64*5+7]*0x100; //HVTN
}