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.
Diff: main.cpp
- Revision:
- 3:764ccaf29ce9
- Parent:
- 2:42e8a4eb3c00
- Child:
- 4:fc56fa8aa794
--- a/main.cpp Fri Aug 10 20:22:44 2012 +0000
+++ b/main.cpp Thu Sep 20 23:45:05 2012 +0000
@@ -7,67 +7,62 @@
DigitalOut RESET (p21);
Serial s(USBTX, USBRX);
-
-int main() {
+DigitalOut finish_flag (LED3);
- //m2s_scan();
-
+int main()
+{
s.printf("DDRO_software starts ...\r\n");
- s.printf("powerReset() ...\r\n");
- //reset
-
- powerReset();
-
- s.printf("powerUp() ...\r\n");
- //power up
- powerUp();
-
- //s.printf("master_write() ...\r\n");
- //master_write();
-
-
+ double voltage = 1;
PLL clk;
- s.printf("testPLL() ...\r\n");
-
- RESET = 0;
- wait_us(10);
- RESET = 1;
-
-
- /*
- for (int i=100;i<201;i+=5)
- {
- clk.setPLL(i);
- double out=(double)5000*(double)i/1024;
- s.printf("Setting PLL, output should be %e k\n", out);
- wait(5);
+ JTAG jtag;
+ int* ro_readings = new int [64];
+ FILE *outFile = fopen("/local/test.out", "a");
+ for (int i=0; i<7; i++) {
+ voltage = 1 - 0.05*i;
+ powerReset();
+ powerUp(voltage);
+ fprintf(outFile, "Voltage: %f\n", voltage);
+ 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]);
+ }
+ int fmax;
+ int lower = 51;
+ int higher = 199;
+ int frequency = (lower+higher)/2;
+ clk.setPLL(frequency))
+ RESET = 0;
+ wait_us(10);
+ RESET = 1;
+ while (higher - lower >1) {
+ if(jtag.JTAG_test()) {
+ lower = frequency;
+ frequency = (lower+higher)/2;
+ clk.setPLL(frequency);
+ RESET = 0;
+ wait_us(10);
+ RESET = 1;
+ } else {
+ higher = frequency;
+ frequency = (lower+higher)/2;
+ clk.setPLL(frequency);
+ RESET = 0;
+ wait_us(10);
+ RESET = 1;
+ }
+ }
+ fprintf(outFile, "fmax %d\n", lower*5);
+ powerDown();
}
- */
-
- clk.setPLL(101);
- /*
- m2s_scan();
-
- //send signal to the other mbed to measure
- //take_meansurement(int command)
- //read_value();
- //receive the value from the other mbed
-
- //listen for power down command from slave
- s.printf("master_read() ...\r\n");
- master_read();
-
- */
- JTAG jtag;
- RESET = 0;
- wait_us(10);
- RESET = 1;
-
- s.printf("testJTAG() ...\r\n");
- jtag.JTAG_test();
- s.printf("powerDown() ...\r\n");
- //power down
- powerDown();
-
+ fclose(outFile);
s.printf("DDRO_software ends.\r\n");
+ while(1) {
+ finish_flag = !finish_flag;
+ wait(1);
+ }
}