A simple hello world program that writes and reads to and from FeRAM

Dependencies:   mbed FeRAM

Files at this revision

API Documentation at this revision

Comitter:
ms523
Date:
Fri Jan 20 14:59:00 2012 +0000
Commit message:

Changed in this revision

FeRAM.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 3d5be81b349a FeRAM.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/FeRAM.lib	Fri Jan 20 14:59:00 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/ms523/code/FeRAM/#f93930fa4df5
diff -r 000000000000 -r 3d5be81b349a main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jan 20 14:59:00 2012 +0000
@@ -0,0 +1,32 @@
+#include "mbed.h"
+#include "FeRAM.h"
+
+FeRAM RAM(p11, p12, p13);
+Serial pc(USBTX,USBRX);
+
+int main() {
+    unsigned char write_array[10], read_array[10];
+
+    // Write to and read back from memory in single bytes
+    for (int i = 0; i < 10; i++) {
+        write_array[i] = i;                     // Set write value
+        RAM.write_byte( i, write_array[i]);     // Write byte
+        read_array[i] = 0;                      // Zero read array
+        read_array[i] = RAM.read_byte(i);       // Read back from memory
+    }
+
+    pc.printf("\n\r Single byte values are: ");
+    for (int i = 0; i < 10; i++) {
+        pc.printf("%d, ",read_array[i]);        // Print read values
+        read_array[i] = 0;                      // Zero read array
+    }
+
+    // Write to and read back from memory in multiple bytes
+    RAM.write_multiple_bytes (100, write_array, 10);
+    RAM.read_multiple_bytes(100, read_array, 10);
+
+    pc.printf("\n\r Multiple byte values are: ");
+    for (int i = 0; i < 10; i++) {
+        pc.printf("%d, ",read_array[i]);        // Print read values
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 3d5be81b349a mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Jan 20 14:59:00 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5364839841bd