⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.htm

📁 AVR 通用 Bootloader 使用说明 *支持多种型号的AVR单片机 *支持多串口的AVR单片机 *支持RS232/RS485/RS422模式 *支持多种通信波特率和时钟频率 *自动计
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title>使用说明</title>
<meta name="author" content="邵子扬">
<style><!--
td { font-size:9pt; }
h1 { font-size:12pt; }
name { font-size:12pt; }
p { font-size:9pt; }
li { font-size:9pt; }
a { font-size:9pt; text-decoration:none; }
a:hover {color:white; background-color:#000000; text-decoration:none; border-style:none; }
--></style>
<meta name="generator" content="Namo WebEditor">
</head>

<body bgcolor="white" text="black" link="blue" vlink="purple" alink="red">
<p><font face="宋体">☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆<a name="b0"> </a><br>
☆ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;☆<br>
☆ &nbsp;AVR 通用 Bootloader 使用说明 &nbsp;☆<br>
☆ &nbsp;</font><span style="background-color:red;"><font face="宋体" color="white">A</font></span><font face="宋体" color="white"><span style="background-color:rgb(255,38,0);">V</span><span style="background-color:rgb(255,76,0);">R</span><span style="background-color:rgb(255,114,0);"> </span><span style="background-color:rgb(255,153,0);">C</span><span style="background-color:rgb(255,178,0);">o</span><span style="background-color:rgb(255,204,0);">m</span><span style="background-color:rgb(255,229,0);">m</span><span style="background-color:yellow;">o</span><span style="background-color:rgb(192,255,0);">n</span><span style="background-color:rgb(128,255,0);"> </span><span style="background-color:rgb(64,255,0);">B</span><span style="background-color:lime;">o</span><span style="background-color:rgb(0,255,64);">o</span><span style="background-color:rgb(0,255,128);">t</span><span style="background-color:rgb(0,255,192);">l</span><span style="background-color:aqua;">o</span><span style="background-color:rgb(0,192,255);">a</span><span style="background-color:rgb(0,128,255);">d</span><span style="background-color:rgb(0,64,240);">e</span><span style="background-color:blue;">r</span><span style="background-color:rgb(64,0,255);">&nbsp;</span><span style="background-color:rgb(128,0,255);">R</span><span style="background-color:rgb(192,0,255);">e</span><span style="background-color:fuchsia;">a</span><span style="background-color:rgb(255,0,192);">d</span><span style="background-color:rgb(255,0,128);">m</span></font><span style="background-color:rgb(255,0,64);"><font face="宋体" color="white">e</font></span><font face="宋体">&nbsp;&nbsp;☆<br>
☆ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;☆<br>
☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆</font></p>
<p><a href="#b1"><font face="宋体">基本介绍</font></a><font face="宋体"><br>
</font><a href="#b2"><font face="宋体">主要特点</font></a><font face="宋体"><br>
</font><a href="#b3"><font face="宋体">程序版本</font></a><font face="宋体"><br>
</font><a href="#b4"><font face="宋体">特别感谢</font></a><font face="宋体"><br>
</font><a href="#b5"><font face="宋体">开发环境</font></a><font face="宋体"><br>
</font><a href="#b6"><font face="宋体">项目文件</font></a><font face="宋体"><br>
</font><a href="#b7"><font face="宋体">使用方法</font></a><font face="宋体"><br>
</font><a href="#b8"><font face="宋体">主要参数</font></a><font face="宋体"><br>
</font><a href="#b9"><font face="宋体">支持型号</font></a><font face="宋体"><br>
</font><a href="#b10"><font face="宋体">常见问题</font></a><font face="宋体"><br>
</font><a href="#b11"><font face="宋体">使用许可</font></a><font face="宋体"></font></p>
<p><font face="宋体">&nbsp;</font></p>
<h1><font face="宋体">基本介绍</font></h1>
<p><font face="宋体">这个程序的主要目的是为了提供一个具有通用性的AVR Bootloader,不同型号的AVR单片机只需要修改一下几个简单的配置参数就可以直接使用了,不用再修改主程序。因为现在网上流传的很多Bootloader程序都是针对某几个特定型号的,在换用其它型号后,需要对程序进行较多的修改,使用起来不太方便,所以我写了这个程序。它是在网上流传的马潮老师的ATmega128 Bootloader程序的基础上,结合了我以前在PIC18单片机中使用Bootloader的一点经验,以及学习自AVR USB中一些使用宏定义的技巧,再经过多次优化后得到的。</font></p>
<p><font face="宋体">这个通用的Bootloader可以支持目前的大部分具有自编程功能,带有Boot区和UART串口的AVR单片机(主要是Mega系列)。如果是带有多串口的单片机,可以任意选择使用其中的一个串口。程序也支持RS485/RS422方式,如果程序稍加修改,也应当可以很容易的支持USI、SPI、I2C等接口。</font></p>
<p><font face="宋体">这个Bootloader已经在ATmega8、ATmega64、ATMega168、ATmega169(Butterfly)等型号的AVR单片机上测试通过。对于其它型号,也基本都编译通过。虽然如此,也无法保证对其它没有经过完全测试的型号上使用不出现问题。如果你发现这个程序在某个型号的单片机上存在问题,请与我联系以便及时修正。</font></p>
<p><font face="宋体">整个Bootloader最大占用不到1K Word的空间。在最小情况下,占用的空间不到300 Word(具体占用空间的大小与单片机的型号、配置的参数、功能裁剪的多少以及程序的优化等级有关)。</font></p>
<p><font face="宋体"><a href="#b0" name="b2">▲</a></font></p>
<h1><font face="宋体">主要特点</font></h1>
<ul>
<li><font face="宋体">支持多种型号的AVR单片机</font></li>
<li><font face="宋体">支持多串口的AVR单片机</font></li>
<li><font face="宋体">支持RS232/RS485/RS422模式</font></li>
<li><font face="宋体">支持多种通信波特率和时钟频率</font></li>
<li><font face="宋体">自动计算波特率误差,如果波特率误差&gt;2%,将给出错误提示</font></li>
<li><font face="宋体">完全C语言编写,容易修改</font></li>
<li><font face="宋体">为移植做了很多优化,将移植的工作量减少到了最低</font></li>
<li><font face="宋体">代码高度优化,占用空间小</font></li>
<li><font face="宋体">方便的功能裁剪,适应不同的要求</font></li>
<li><font face="宋体">支持看门狗</font></li>
<li><font face="宋体">支持使用LED指示升级状态</font></li>
<li><font face="宋体">支持超级终端下载</font></li>
<li><font face="宋体">...</font></li>
</ul>
<p><font face="宋体"><a href="#b0" name="b3">▲</a></font></p>
<h1><font face="宋体">程序版本</font></h1>
<table width="100%" cellpadding="0" cellspacing="0">
    <tr>
        <td valign="top" width="50">
            <p><font face="宋体">v1.0</font></p>
        </td>
        <td valign="top" width="100">
            <p><font face="宋体">2007.Mar.22</font></p>
        </td>
<td valign="top">
<p><font face="宋体">第一版,实现全部基本功能,并扩展了XModem协议以适合不同的应用(可变缓冲区长度和多种校验方式)。</font></p>
</td>
    </tr>
<tr>
<td valign="top" width="50"><font face="宋体">&nbsp;</font></td>
<td valign="top" width="100"><font face="宋体">&nbsp;</font></td>
<td valign="top"><font face="宋体">&nbsp;</font></td>
</tr>
</table>
<p><font face="宋体"><a href="#b0" name="b4">▲</a></font></p>
<h1><font face="宋体">特别感谢</font></h1>
<p><font face="宋体">在此特别感谢下面这些为此程序做出贡献的人:</font></p>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="100">
<p><font face="宋体">刘海涛 </font></p>
</td>
<td width="990">
<p><font face="宋体">我的同事,在程序编写和调试时提供了很多帮助和资料</font></p>
</td>
</tr>
<tr>
<td width="100"><font face="宋体">&nbsp;</font></td>
<td width="990"><font face="宋体">&nbsp;</font></td>
</tr>
</table>
<p><font face="宋体">&nbsp;</font></p>
<p><font face="宋体"><a href="#b0" name="b5">▲</a></font></p>
<h1><font face="宋体">开发环境</font></h1>
<p><font face="宋体">本项目的开发环境是:WinAVR + AVR Studio</font></p>
<p><font face="宋体">WinAVR版本: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20070122<br>
AVR Studio版本: &nbsp;&nbsp;&nbsp;4.13.258</font></p>
<p><font face="宋体">本项目中所有文件都以AVR Studio作为IDE进行调试,可以使用mk-II仿真器或其他仿真工具调试。使用AVR Studio的好处是可以不用手工修改makefile文件,不容易出错,降低了初学者上手的难度。WinAVR可以在 </font><a href="http://winavr.sourceforge.net/" target="_blank"><font face="宋体">http://winavr.sourceforge.net/</font></a><font face="宋体"> 下载,AVR Studio可以在 </font><a href="http://www.atmel.com/" target="_blank"><font face="宋体">http://www.atmel.com/</font></a><font face="宋体"> 下载,它们都是免费软件。</font></p>
<p><font face="宋体"><a href="#b0" name="b6">▲</a></font></p>
<h1><font face="宋体">项目文件</font></h1>
<p><font face="宋体">整个Bootloader主要由以下几个文件组成:</font></p>
<p><font face="宋体">bootldr.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;主程序<br>
bootldr.h &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;主程序的头文件<br>
bootcfg.h &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;主程序的用户配置文件<br>
test.c &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;串口通信的测试程序<br>
testcfg.h &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;test.c的配置文件<br>
readme.txt &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;本说明文件</font></p>
<p><font face="宋体"><a href="#b0" name="b7">▲</a></font></p>
<h1><font face="宋体">使用方法</font></h1>
<ol>
<li><font face="宋体">建立一个新的项目,并将上面的文件复制到新项目的文件夹中;</font></li>
<li><font face="宋体">添加bootldr.c、bootldr.h、bootcfg.h三个文件到项目中;</font></li>
<li><font face="宋体">在bootcfg.h中修改配置参数;</font></li>
<li><font face="宋体">设置项目的内存段地址为Bootloader的起始地址,在AVR Studio中设置时注意地址是按照字(word)计算的;</font></li>
<li><font face="宋体">编译项目,产生目标文件;</font></li>
<li><font face="宋体">使用编程器烧录HEX目标文件到单片机;</font></li>
<li><font face="宋体">设置相应的加密位和熔丝位,设置Boot区大小和Boot Reset向量;</font></li>
<li><font face="宋体">通过串口联机,进行升级测试。</font></li>
</ol>
<p><font face="宋体"><a href="#b0" name="b8">▲</a></font></p>
<h1><font face="宋体">主要参数</font></h1>
<p><font face="宋体">下面的参数很重要,请按照用户系统的要求仔细设置:</font></p>
<table border="1" width="100%" cellspacing="0" bordercolordark="white" bordercolorlight="black">
<tr>
<td width="100">
<p><font face="宋体">BUFFERSIZE</font></p>
</td>
<td>
<p><font face="宋体">串口缓冲区大小,使用超级终端时=128。这个参数应当是单片机页面大小SPM_PAGESIZE的倍数或约数</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">F_CPU </font></p>
</td>
<td>
<p><font face="宋体">系统时钟频率(Hz)</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">BAUDRATE</font></p>
</td>
<td>
<p><font face="宋体">串口波特率(bps)</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">LEVELMODE</font></p>
</td>
<td>
<p><font face="宋体">Bootloader触发模式 0=串口 1=电平</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">timeclk</font></p>
</td>
<td>
<p><font face="宋体">基本时间间隔(ms)</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">TimeOutCnt</font></p>
</td>
<td>
<p><font face="宋体">Bootloader启动超时计数&lt;=255</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">TimeOutCntC</font></p>
</td>
<td>
<p><font face="宋体">等待接收文件的超时计数&lt;=255</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">CONNECTCNT</font></p>
</td>
<td>
<p><font face="宋体">联机密码长度</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">KEY</font></p>
</td>
<td>
<p><font face="宋体">联机密码,任意16进制数或字符串</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">COMPORTNo</font></p>
</td>
<td>
<p><font face="宋体">串口号,多串口的单片机是串口号(0/1/2...),单串口的单片机一般是空,也有的需要设置为0(特别是新的型号,如ATmega168)</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">WDGEn</font></p>
</td>
<td>
<p><font face="宋体">使能看门狗</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">RS485</font></p>
</td>
<td>
<p><font face="宋体">使能RS485/RS422</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">RS485PORT</font></p>
</td>
<td>
<p><font face="宋体">RS485/RS422发送控制端口=A/B/C/D...</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">RS485TXEn</font></p>
</td>
<td>
<p><font face="宋体">RS485/RS422发送控制引脚=PC0/PC1/PC2...</font></p>
</td>
</tr>
<tr>
<td width="100">
<p><font face="宋体">LEDEn</font></p>
</td>
<td>
<p><font face="宋体">LED状态指示使能</font></p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -