Simple example of how to use the device library for RAMTRON FM25W256.

Dependencies:   mbed FM25W256

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "fm25w256.h"
00003 
00004 Serial pc(USBTX, USBRX);
00005 
00006 int main() 
00007 {
00008     unsigned char cRX[16];
00009     unsigned char cTX[16];
00010     int x;
00011     
00012     for(x=0; x<16; x++) cRX[x]=0;
00013     for(x=0; x<16; x++) cTX[x]=0;
00014     
00015     FM25W_SSP1_Init();
00016   
00017     pc.printf("\nOut of reset, memory contained:\n");
00018     FM25W_ReadBlock(0,cRX,16);                          //read 16 bytes
00019     for(x=0; x<16; x++) pc.printf("%02X ", cRX[x]);     //display them
00020     
00021     FM25W_WriteBlock(0, cTX, 16);                       //clear memory addresses
00022     
00023     for(x=0; x<16; x++) cTX[x]=x;                       //prepare sample bytes
00024     
00025     pc.printf("\nMemory 'before' contains:\n");
00026     FM25W_ReadBlock(0,cRX,16);                          //read 16 bytes
00027     for(x=0; x<16; x++) pc.printf("%02X ", cRX[x]);     //display them
00028     
00029     pc.printf("\nWriting data to memory...");
00030     FM25W_WriteBlock(0,cTX,16);                         //write 16 bytes
00031     
00032     for(x=0; x<16; x++) cRX[x]=0;                       //clear RX buffer
00033     
00034     pc.printf("\nReading data from memory...");
00035     FM25W_ReadBlock(0,cRX,16);                          //read 16 bytes
00036     
00037     pc.printf("\nMemory 'after' contains:\n");
00038     for(x=0; x<16; x++) pc.printf("%02X ", cRX[x]);     //display bytes
00039     
00040 
00041     while(1) 
00042     {
00043 
00044     }
00045 }