Self_programming_main.c File Reference


Detailed Description

Atmel Corporation

Revision
2.0
Date
Wednesday, January 18, 2006 15:18:52 UTC

Definition in file Self_programming_main.c.

#include <ioavr.h>
#include <inavr.h>
#include "Self_programming.h"

Include dependency graph for Self_programming_main.c:

Go to the source code of this file.

Functions

__C_task main (void)


Function Documentation

__C_task main void   ) 
 

Definition at line 32 of file Self_programming_main.c.

References RecoverFlash().

00032                      {
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 }

Here is the call graph for this function:


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