Martin Smith
/
FeRAM_Hello_World
A simple hello world program that writes and reads to and from FeRAM
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "FeRAM.h" 00003 00004 FeRAM RAM(p11, p12, p13); 00005 Serial pc(USBTX,USBRX); 00006 00007 int main() { 00008 unsigned char write_array[10], read_array[10]; 00009 00010 // Write to and read back from memory in single bytes 00011 for (int i = 0; i < 10; i++) { 00012 write_array[i] = i; // Set write value 00013 RAM.write_byte( i, write_array[i]); // Write byte 00014 read_array[i] = 0; // Zero read array 00015 read_array[i] = RAM.read_byte(i); // Read back from memory 00016 } 00017 00018 pc.printf("\n\r Single byte values are: "); 00019 for (int i = 0; i < 10; i++) { 00020 pc.printf("%d, ",read_array[i]); // Print read values 00021 read_array[i] = 0; // Zero read array 00022 } 00023 00024 // Write to and read back from memory in multiple bytes 00025 RAM.write_multiple_bytes (100, write_array, 10); 00026 RAM.read_multiple_bytes(100, read_array, 10); 00027 00028 pc.printf("\n\r Multiple byte values are: "); 00029 for (int i = 0; i < 10; i++) { 00030 pc.printf("%d, ",read_array[i]); // Print read values 00031 } 00032 }
Generated on Fri Jul 15 2022 11:04:03 by 1.7.2