📄 main.lis
字号:
.module main.c
.area text(rom, con, rel)
0000 .dbfile E:\icc\peterf\BootLoad\main.c
0000 .dbfunc e FlashLoad _FlashLoad fV
.even
0000 _FlashLoad::
0000 .dbline -1
0000 .dbline 120
0000 ; /******************************************************************************
0000 ; Atmega系列单片机 BootLoad程序
0000 ; 日 期:2004年的最后一天
0000 ; 肖 鹏 www.527dz.com 527dz@527dz.com
0000 ;
0000 ; /*****************************************************************************/
0000 ; #include <macros.h>
0000 ; #include "assembly.h"
0000 ; //×××××××××××××××××××××××××××××××××××××××××××××××××××××××××
0000 ; #define fosc 8000000 //晶振频率
0000 ; #define baud1 38400 //波特率
0000 ; //请根据目标板选择芯片型号
0000 ; //#define ChipType Atmega8
0000 ; //#define ChipType Atmega16
0000 ; //#define ChipType Atmega32
0000 ; //#define ChipType Atmega64
0000 ; #define ChipType Atmega128
0000 ; //#define ChipType Atmega8515
0000 ; //#define ChipType Atmega8535
0000 ; //*********************************************************
0000 ; //选择BOOT区大小
0000 ; //#define BootSize 'a' //128
0000 ; //#define BootSize 'b' //256
0000 ; //#define BootSize 'c' //512
0000 ; #define BootSize 'd' //1024
0000 ; //#define BootSize 'e' //2048(不知道是否有2048字BOOT空间的芯片)
0000 ; //选择BootLoad版本号
0000 ; #define BootVer 'f' //1.0版本
0000 ; //#define BootVer 'g' //1.1版本
0000 ; //#define BootVer 'h' //1.2版本
0000 ; //#define BootVer 'i' //1.3版本
0000 ; //#define BootVer 'j' //1.4版本
0000 ; //#define BootVer 'k' //1.5版本
0000 ; //#define BootVer 'l' //1.6版本
0000 ; //#define BootVer 'm' //1.7版本
0000 ; //#define BootVer 'n' //1.8版本
0000 ; //#define BootVer 'o' //1.9版本
0000 ; //#define BootVer 'p' //2.0版本(应该是最终版本了)
0000 ; //**********************************************************
0000 ; #define Atmega8 0x30
0000 ; #define Atmega16 0x31
0000 ; #define Atmega32 0x32
0000 ; #define Atmega64 0x33
0000 ; #define Atmega128 0x34
0000 ; #define Atmega8515 0x35
0000 ; #define Atmega8535 0x36
0000 ; //*****************************************************************************
0000 ; #define InteClk //是否使用内部时钟
0000 ; #define OscAddress 0x1fff //时钟校准值存储地址
0000 ; //#define OscAddress 0x3fff //时钟校准值存储地址
0000 ; //*****************************************************************************
0000 ; //8时钟下的波特率设置
0000 ; //#define BAU 103 //4800
0000 ; //#define BAU 51 //9600
0000 ; //#define BAU 34 //14400
0000 ; #define BAU 25 //19200
0000 ; //*****************************************************************************
0000 ; #if (ChipType == Atmega8)
0000 ; #include "iom8v.h"
0000 ; #define PageByte 64
0000 ; #define AddressShift 6
0000 ; #define INTVECREG GICR
0000 ; #endif
0000 ;
0000 ; #if (ChipType == Atmega16)
0000 ; #include "iom16v.h"
0000 ; #define PageByte 128
0000 ; #define AddressShift 7
0000 ; #define INTVECREG GICR
0000 ; #endif
0000 ;
0000 ; #if (ChipType == Atmega32)
0000 ; #include "iom32v.h"
0000 ; #define PageByte 128
0000 ; #define AddressShift 7
0000 ; #define INTVECREG GICR
0000 ; #endif
0000 ;
0000 ; #if (ChipType == Atmega64)
0000 ; #include "iom64v.h"
0000 ; #define PageByte 256
0000 ; #define AddressShift 8
0000 ; #define INTVECREG MCUCR
0000 ; #endif
0000 ;
0000 ; #if (ChipType == Atmega128)
0000 ; #include "iom128v.h"
0000 ; #define PageByte 256
0000 ; #define AddressShift 8
0000 ; #define INTVECREG MCUCR
0000 ; #define RAMPZ_FLAG
0000 ; #endif
0000 ;
0000 ; #if (ChipType == Atmega8515)
0000 ; #include "iom8515v.h"
0000 ; #define PageByte 64
0000 ; #define AddressShift 6
0000 ; #define INTVECREG GICR
0000 ; #endif
0000 ;
0000 ; void FlashLoad (void);
0000 ; void GetPageNumber (void);
0000 ; void ExecCode (void);
0000 ; char GetPage (void);
0000 ; void WriteFlash (void);
0000 ; char CheckFlash (void);
0000 ; unsigned char IsChar (void);
0000 ; void SendChar (unsigned char c);
0000 ; void delay (void); //1ms延时函数
0000 ; unsigned char RecChar (void);
0000 ;
0000 ; unsigned char PageBuffer[PageByte];
0000 ; unsigned int RealPageAddress;
0000 ; unsigned int PageAddress;
0000 ;
0000 ; /*****************************************************************************/
0000 ; //Flash编程
0000 ; /*****************************************************************************/
0000 ; void FlashLoad(void)
0000 ; {
0000 .dbline 121
0000 ; SendChar('!');
0000 01E2 ldi R16,33
0002 E9D0 xcall _SendChar
0004 19C0 xjmp L3
0006 L2:
0006 .dbline 123
0006 ; while (1)
0006 ; {
0006 .dbline 124
0006 ; GetPageNumber();
0006 1AD0 xcall _GetPageNumber
0008 .dbline 126
0008 ;
0008 ; if (RealPageAddress == 0xffff)
0008 80910200 lds R24,_RealPageAddress
000C 90910300 lds R25,_RealPageAddress+1
0010 8F3F cpi R24,255
0012 EFEF ldi R30,255
0014 9E07 cpc R25,R30
0016 09F4 brne L5
0018 .dbline 127
0018 ; return;
0018 10C0 xjmp L1
001A L5:
001A .dbline 129
001A ;
001A ; if (GetPage())
001A 2CD0 xcall _GetPage
001C 0023 tst R16
001E 51F0 breq L7
0020 .dbline 130
0020 ; {
0020 .dbline 131
0020 ; WriteFlash();
0020 65D0 xcall _WriteFlash
0022 .dbline 132
0022 ; if (CheckFlash())
0022 97D0 xcall _CheckFlash
0024 0023 tst R16
0026 19F0 breq L9
0028 .dbline 133
0028 ; SendChar('!');
0028 01E2 ldi R16,33
002A D5D0 xcall _SendChar
002C 05C0 xjmp L8
002E L9:
002E .dbline 135
002E ; else
002E ; SendChar('@');
002E 00E4 ldi R16,64
0030 D2D0 xcall _SendChar
0032 .dbline 136
0032 ; }
0032 02C0 xjmp L8
0034 L7:
0034 .dbline 138
0034 ; else
0034 ; SendChar('@');
0034 00E4 ldi R16,64
0036 CFD0 xcall _SendChar
0038 L8:
0038 .dbline 139
0038 L3:
0038 .dbline 122
0038 E6CF xjmp L2
003A X0:
003A .dbline -2
003A .dbline 140
003A ; }
003A ; }
003A L1:
003A .dbline 0 ; func end
003A 0895 ret
003C .dbend
003C .dbfunc e GetPageNumber _GetPageNumber fV
003C ; PageAddressL -> R22
003C ; PageAddressH -> R20
.even
003C _GetPageNumber::
003C 0E940000 xcall push_gset2
0040 .dbline -1
0040 .dbline 144
0040 ;
0040 ; /*****************************************************************************/
0040 ; void GetPageNumber(void)
0040 ; {
0040 .dbline 148
0040 ; unsigned char PageAddressH;
0040 ; unsigned char PageAddressL;
0040 ;
0040 ; PageAddressH = RecChar();
0040 C3D0 xcall _RecChar
0042 402F mov R20,R16
0044 .dbline 150
0044 ;
0044 ; PageAddressL = RecChar();
0044 C1D0 xcall _RecChar
0046 602F mov R22,R16
0048 .dbline 152
0048 ;
0048 ; RealPageAddress=(int)((PageAddressH << 8) + PageAddressL);
0048 342E mov R3,R20
004A 262E mov R2,R22
004C 30920300 sts _RealPageAddress+1,R3
0050 20920200 sts _RealPageAddress,R2
0054 .dbline 153
0054 ; PageAddress=RealPageAddress<<AddressShift;
0054 322C mov R3,R2
0056 2224 clr R2
0058 30920100 sts _PageAddress+1,R3
005C 20920000 sts _PageAddress,R2
0060 .dbline 155
0060 ; #ifdef RAMPZ_FLAG
0060 ; if (PageAddressH)
0060 4423 tst R20
0062 19F0 breq L12
0064 .dbline 156
0064 ; RAMPZ = 1;
0064 81E0 ldi R24,1
0066 8BBF out 0x3b,R24
0068 02C0 xjmp L13
006A L12:
006A .dbline 158
006A 2224 clr R2
006C 2BBE out 0x3b,R2
006E L13:
006E .dbline -2
006E .dbline 164
006E ; else
006E ; RAMPZ = 0;
006E ; #endif
006E ; //SendChar(RealPageAddress>>8);
006E ; //SendChar(RealPageAddress);
006E ; //SendChar(PageAddress>>8);
006E ; //SendChar(PageAddress);
006E ; }
006E L11:
006E 0E940000 xcall pop_gset2
0072 .dbline 0 ; func end
0072 0895 ret
0074 .dbsym r PageAddressL 22 c
0074 .dbsym r PageAddressH 20 c
0074 .dbend
0074 .dbfunc e GetPage _GetPage fc
0074 ; CheckSum -> R20
0074 ; LocalCheckSum -> R22
0074 ; i -> R10
.even
0074 _GetPage::
0074 0E940000 xcall push_gset3
0078 .dbline -1
0078 .dbline 168
0078 ;
0078 ; /*****************************************************************************/
0078 ; char GetPage(void)
0078 ; {
0078 .dbline 170
0078 ; unsigned char i;
0078 ; unsigned char LocalCheckSum = 0;
0078 6627 clr R22
007A .dbline 171
007A ; unsigned char CheckSum = 0;
007A 4427 clr R20
007C .dbline 173
007C ;
007C ; for (i=0;i<PageByte/2;i++)
007C AA24 clr R10
007E 12C0 xjmp L18
0080 X1:
0080 .dbline 174
0080 ; {
0080 L19:
0080 .dbline 175
0080 L20:
0080 .dbline 175
0080 9BD0 xcall _IsChar
0082 0023 tst R16
0084 E9F3 breq L19
0086 .dbline 176
0086 A0D0 xcall _RecChar
0088 80E0 ldi R24,<_PageBuffer
008A 90E0 ldi R25,>_PageBuffer
008C EA2D mov R30,R10
008E FF27 clr R31
0090 E80F add R30,R24
0092 F91F adc R31,R25
0094 0083 std z+0,R16
0096 .dbline 177
0096 EA2D mov R30,R10
0098 FF27 clr R31
009A E80F add R30,R24
009C F91F adc R31,R25
009E 2080 ldd R2,z+0
00A0 6225 eor R22,R2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -