📄 self__programming__main_8c.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>AVR106 - C Functions for Reading and Writing to Flash Memory: Self_programming_main.c File Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.5 --><div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> </ul></div><div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>Globals</span></a></li> </ul></div><h1>Self_programming_main.c File Reference</h1><hr><a name="_details"></a><h2>Detailed Description</h2>Atmel Corporation<p><ul><li>File : <a class="el" href="Self__programming__main_8c.html">Self_programming_main.c</a></li><li>Compiler : IAR EWAVR 2.28a / 3.10c and newer</li></ul><p><ul><li>Support mail : <a href="mailto:avr@atmel.com">avr@atmel.com</a></li></ul><p><ul><li>Supported devices : This example is written for ATmega128.</li></ul><p><ul><li>AppNote : AVR106 - C functions for reading and writing to flash memory.</li></ul><p><ul><li>Description : The file contains an example program using the Flash R/W functions provided with the files <a class="el" href="Self__programming_8h.html">Self_programming.h</a> / <a class="el" href="Self__programming_8c.html">Self_programming.c</a> . The program should be compiled using a linker file (*.xcl) that is configured to place the entire program code into the Boot section of the Flash memory. Please refer to the application note document for more information.</li></ul><p><dl compact><dt><b>Revision</b></dt><dd>2.0 </dd></dl><dl compact><dt><b>Date</b></dt><dd>Wednesday, January 18, 2006 15:18:52 UTC </dd></dl><p>Definition in file <a class="el" href="Self__programming__main_8c-source.html">Self_programming_main.c</a>.<p><code>#include <ioavr.h></code><br><code>#include <inavr.h></code><br><code>#include "<a class="el" href="Self__programming_8h-source.html">Self_programming.h</a>"</code><br><p>Include dependency graph for Self_programming_main.c:<p><center><img src="Self__programming__main_8c__incl.png" border="0" usemap="#Self_programming_main.c_map" alt=""></center><map name="Self_programming_main.c_map"><area href="Self__programming_8h-source.html" shape="rect" coords="236,108,380,135" alt=""></map><p><a href="Self__programming__main_8c-source.html">Go to the source code of this file.</a><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr><tr><td colspan="2"><br><h2>Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">__C_task </td><td class="memItemRight" valign="bottom"><a class="el" href="Self__programming__main_8c.html#5f8568da681b2f2e2d477eb47f8e1325">main</a> (void)</td></tr></table><hr><h2>Function Documentation</h2><a class="anchor" name="5f8568da681b2f2e2d477eb47f8e1325"></a><!-- doxytag: member="Self_programming_main.c::main" ref="5f8568da681b2f2e2d477eb47f8e1325" args="(void)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">__C_task main </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p><p>Definition at line <a class="el" href="Self__programming__main_8c-source.html#l00032">32</a> of file <a class="el" href="Self__programming__main_8c-source.html">Self_programming_main.c</a>.<p>References <a class="el" href="Self__programming_8c-source.html#l00178">RecoverFlash()</a>.<div class="fragment"><pre class="fragment"><a name="l00032"></a>00032 {<a name="l00033"></a>00033 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> testBuffer1[PAGESIZE]; <span class="comment">// Declares variables for testing</span><a name="l00034"></a>00034 <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> testBuffer2[PAGESIZE]; <span class="comment">// Note. Each array uses PAGESIZE bytes of</span><a name="l00035"></a>00035 <span class="comment">// code stack</span><a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> testChar; <span class="comment">// A warning will come saying that this var is set but never used. Ignore it.</span><a name="l00038"></a>00038 <span class="keywordtype">int</span> index;<a name="l00039"></a>00039 MCUCR |= (1<<IVSEL); <span class="comment">// Move interrupt vectors to boot</span><a name="l00040"></a>00040 <a class="code" href="Self__programming_8c.html#dab3fc05882b5f5511a24d423119e003">RecoverFlash</a>();<a name="l00041"></a>00041 <span class="keywordflow">for</span>(index=0; index<PAGESIZE; index++){<a name="l00042"></a>00042 testBuffer1[index]=(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>)index; <span class="comment">// Fills testBuffer1 with values 0,1,2..255</span><a name="l00043"></a>00043 }<a name="l00044"></a>00044 <span class="keywordflow">for</span>(;;){<a name="l00045"></a>00045 <a class="code" href="Self__programming_8c.html#fc13c9dcc9565c691d73a8e35ea3c3b0">WriteFlashPage</a>(0x200, testBuffer1); <span class="comment">// Writes testbuffer1 to Flash page 2</span><a name="l00046"></a>00046 <span class="comment">// Function returns TRUE</span><a name="l00047"></a>00047 <a class="code" href="Self__programming_8c.html#8b290614a2b685c107c6eed5a9db96d4">ReadFlashPage</a>(0x200, testBuffer2); <span class="comment">// Reads back Flash page 2 to TestBuffer2</span><a name="l00048"></a>00048 <span class="comment">// Function returns TRUE</span><a name="l00049"></a>00049 <a class="code" href="Self__programming_8c.html#37868fe819d4b22e28890f3c0d3797fa">WriteFlashByte</a>(0x204, 0x38); <span class="comment">// Writes 0x38 to byte address 0x204</span><a name="l00050"></a>00050 <span class="comment">// Same as byte 4 on page 2</span><a name="l00051"></a>00051 <span class="comment">// Returns TRUE</span><a name="l00052"></a>00052 testChar = <a class="code" href="Self__programming_8c.html#1d6ded0de0674f00a82507424c862431">ReadFlashByte</a>(0x204); <span class="comment">// Reads back value from address 0x204</span><a name="l00053"></a>00053 }<a name="l00054"></a>00054 }</pre></div><p><p>Here is the call graph for this function:<p><center><img src="Self__programming__main_8c_5f8568da681b2f2e2d477eb47f8e1325_cgraph.png" border="0" usemap="#Self__programming__main_8c_5f8568da681b2f2e2d477eb47f8e1325_cgraph_map" alt=""></center><map name="Self__programming__main_8c_5f8568da681b2f2e2d477eb47f8e1325_cgraph_map"><area href="Self__programming_8c.html#dab3fc05882b5f5511a24d423119e003" shape="rect" coords="109,7,213,33" alt=""><area href="Self__programming_8c.html#d29e91755e1d3695b74c15e89019db39" shape="rect" coords="264,7,384,33" alt=""></map> </td> </tr></table><hr size="1"><address style="align: right;"><small>Generated on Wed Jan 18 16:19:25 2006 for AVR106 - C Functions for Reading and Writing to Flash Memory by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.5 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -