Self_programming_main.c

Go to the documentation of this file.
00001 // This file has been prepared for Doxygen automatic documentation generation.
00028 #include <ioavr.h>
00029 #include <inavr.h>
00030 #include "Self_programming.h"
00031 
00032 __C_task main( void ){
00033   unsigned char testBuffer1[PAGESIZE];      // Declares variables for testing
00034   unsigned char testBuffer2[PAGESIZE];      // Note. Each array uses PAGESIZE bytes of
00035                                             // code stack
00036 
00037   static unsigned char testChar; // A warning will come saying that this var is set but never used. Ignore it.
00038   int index;
00039   MCUCR |= (1<<IVSEL);                      // Move interrupt vectors to boot
00040   RecoverFlash();
00041   for(index=0; index<PAGESIZE; index++){
00042     testBuffer1[index]=(unsigned char)index; // Fills testBuffer1 with values 0,1,2..255
00043   }
00044   for(;;){
00045     WriteFlashPage(0x200, testBuffer1);     // Writes testbuffer1 to Flash page 2
00046                                             // Function returns TRUE
00047     ReadFlashPage(0x200, testBuffer2);      // Reads back Flash page 2 to TestBuffer2
00048                                             // Function returns TRUE
00049     WriteFlashByte(0x204, 0x38);            // Writes 0x38 to byte address 0x204
00050                                             // Same as byte 4 on page 2
00051                                             // Returns TRUE
00052     testChar = ReadFlashByte(0x204);        // Reads back value from address 0x204
00053   }
00054 }

Generated on Wed Jan 18 16:19:21 2006 for AVR106 - C Functions for Reading and Writing to Flash Memory by  doxygen 1.4.5