📄 eeprom.lis
字号:
.module eeprom.c
.area text(rom, con, rel)
0000 .dbfile E:\avrwork3_pt100\eeprom.c
0000 .dbfunc e EEPROMread _EEPROMread fc
0000 ; location -> R16,R17
.even
0000 _EEPROMread::
0000 .dbline -1
0000 .dbline 6
0000 ; #include <iom16v.h>
0000 ; #include <macros.h>
0000 ;
0000 ;
0000 ; unsigned char EEPROMread( int location)
0000 ; {
0000 L2:
0000 .dbline 7
0000 L3:
0000 .dbline 7
0000 ; while (EECR & 0x02); // Wait until any earlier write is done.
0000 E199 sbic 0x1c,1
0002 FECF rjmp L2
0004 .dbline 15
0004 ; // This is just a safety incase a write
0004 ; // was done and is not completed when
0004 ; // the read was called. If this test is
0004 ; // not done, the current write operation
0004 ; // will fail due to that the address or
0004 ; // data is changed.
0004 ;
0004 ; EEAR = location;
0004 1FBB out 0x1f,R17
0006 0EBB out 0x1e,R16
0008 .dbline 17
0008 ;
0008 ; EECR |= 0x01; // Set READ strobe
0008 E09A sbi 0x1c,0
000A .dbline 19
000A ;
000A ; return (EEDR); // Return byte
000A 0DB3 in R16,0x1d
000C .dbline -2
000C L1:
000C .dbline 0 ; func end
000C 0895 ret
000E .dbsym r location 16 I
000E .dbend
000E .dbfunc e EEPROMReadBytes _EEPROMReadBytes fV
000E ; dst -> R10,R11
000E ; size -> R12,R13
000E ; ptr -> y+6
000E ; addr -> R14,R15
.even
000E _EEPROMReadBytes::
000E 3A93 st -y,r19
0010 2A93 st -y,r18
0012 0E940000 xcall push_gset5x
0016 7801 movw R14,R16
0018 C884 ldd R12,y+8
001A D984 ldd R13,y+9
001C .dbline -1
001C .dbline 24
001C ; }
001C ;
001C ;
001C ; void EEPROMReadBytes(int addr, void *ptr, int size)
001C ; {
001C .dbline 25
001C ; char *dst = ptr;
001C AE80 ldd R10,y+6
001E BF80 ldd R11,y+7
0020 0AC0 xjmp L7
0022 L6:
0022 .dbline 28
0022 .dbline 29
0022 8701 movw R16,R14
0024 EDDF xcall _EEPROMread
0026 F501 movw R30,R10
0028 0083 std z+0,R16
002A .dbline 30
002A C701 movw R24,R14
002C 0196 adiw R24,1
002E 7C01 movw R14,R24
0030 .dbline 31
0030 CF01 movw R24,R30
0032 0196 adiw R24,1
0034 5C01 movw R10,R24
0036 .dbline 32
0036 L7:
0036 .dbline 27
0036 ;
0036 ; while (size--)
0036 1601 movw R2,R12
0038 C101 movw R24,R2
003A 0197 sbiw R24,1
003C 6C01 movw R12,R24
003E 2220 tst R2
0040 81F7 brne L6
0042 3320 tst R3
0044 71F7 brne L6
0046 X0:
0046 .dbline -2
0046 L5:
0046 0E940000 xcall pop_gset5x
004A 2296 adiw R28,2
004C .dbline 0 ; func end
004C 0895 ret
004E .dbsym r dst 10 pc
004E .dbsym r size 12 I
004E .dbsym l ptr 6 pV
004E .dbsym r addr 14 I
004E .dbend
004E .dbfunc e EEPROMwrite _EEPROMwrite fI
004E ; oldSREG -> R10
004E ; byte -> R18
004E ; location -> R16,R17
.even
004E _EEPROMwrite::
004E 0E940000 xcall push_gset3x
0052 .dbline -1
0052 .dbline 37
0052 ; {
0052 ; *dst = EEPROMread(addr);
0052 ; addr++;
0052 ; dst++;
0052 ; }
0052 ; }
0052 ;
0052 ;
0052 ; int EEPROMwrite( int location, unsigned char byte)
0052 ; {
0052 L10:
0052 .dbline 40
0052 L11:
0052 .dbline 40
0052 ; unsigned char oldSREG;
0052 ;
0052 ; while (EECR & 0x02); // Wait until any earlier write is done
0052 E199 sbic 0x1c,1
0054 FECF rjmp L10
0056 .dbline 42
0056 ;
0056 ; EEAR = location;
0056 1FBB out 0x1f,R17
0058 0EBB out 0x1e,R16
005A .dbline 44
005A ;
005A ; EEDR = byte;
005A 2DBB out 0x1d,R18
005C .dbline 46
005C ;
005C ; oldSREG = SREG;
005C AFB6 in R10,0x3f
005E .dbline 47
005E ; SREG &= ~0x80; // disable interrupt
005E F894 bclr 7
0060 .dbline 49
0060 ;
0060 ; EECR |= 0x04; // Set MASTER WRITE enable
0060 E29A sbi 0x1c,2
0062 .dbline 50
0062 ; EECR |= 0x02; // Set WRITE strobe
0062 E19A sbi 0x1c,1
0064 .dbline 52
0064 ;
0064 ; SREG = oldSREG;
0064 AFBE out 0x3f,R10
0066 .dbline 53
0066 ; return 0; // return Success.
0066 0027 clr R16
0068 1127 clr R17
006A .dbline -2
006A L9:
006A 0E940000 xcall pop_gset3x
006E .dbline 0 ; func end
006E 0895 ret
0070 .dbsym r oldSREG 10 c
0070 .dbsym r byte 18 c
0070 .dbsym r location 16 I
0070 .dbend
0070 .dbfunc e EEPROMWriteBytes _EEPROMWriteBytes fV
0070 ; src -> R10,R11
0070 ; size -> R12,R13
0070 ; ptr -> y+6
0070 ; addr -> R14,R15
.even
0070 _EEPROMWriteBytes::
0070 3A93 st -y,r19
0072 2A93 st -y,r18
0074 0E940000 xcall push_gset5x
0078 7801 movw R14,R16
007A C884 ldd R12,y+8
007C D984 ldd R13,y+9
007E .dbline -1
007E .dbline 62
007E ; // Could be expanded so that
007E ; // the routine checks that the address
007E ; // is within the range of the chip.
007E ; }
007E ;
007E ;
007E ;
007E ; void EEPROMWriteBytes(int addr, void *ptr, int size)
007E ; {
007E .dbline 63
007E ; char *src = ptr;
007E AE80 ldd R10,y+6
0080 BF80 ldd R11,y+7
0082 0AC0 xjmp L15
0084 L14:
0084 .dbline 66
0084 .dbline 67
0084 F501 movw R30,R10
0086 2081 ldd R18,z+0
0088 8701 movw R16,R14
008A E1DF xcall _EEPROMwrite
008C .dbline 68
008C C701 movw R24,R14
008E 0196 adiw R24,1
0090 7C01 movw R14,R24
0092 .dbline 69
0092 C501 movw R24,R10
0094 0196 adiw R24,1
0096 5C01 movw R10,R24
0098 .dbline 70
0098 L15:
0098 .dbline 65
0098 ;
0098 ; while (size--)
0098 1601 movw R2,R12
009A C101 movw R24,R2
009C 0197 sbiw R24,1
009E 6C01 movw R12,R24
00A0 2220 tst R2
00A2 81F7 brne L14
00A4 3320 tst R3
00A6 71F7 brne L14
00A8 X1:
00A8 .dbline -2
00A8 L13:
00A8 0E940000 xcall pop_gset5x
00AC 2296 adiw R28,2
00AE .dbline 0 ; func end
00AE 0895 ret
00B0 .dbsym r src 10 pc
00B0 .dbsym r size 12 I
00B0 .dbsym l ptr 6 pV
00B0 .dbsym r addr 14 I
00B0 .dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -