📄 eeprom读写.lst
字号:
__text_start:
__start:
13 E5CF LDI R28,0x5F
14 E0D4 LDI R29,4
15 BFCD OUT 0x3D,R28
16 BFDE OUT 0x3E,R29
17 51CE SUBI R28,0x1E
18 40D0 SBCI R29,0
19 EA0A LDI R16,0xAA
1A 8308 STD Y+0,R16
1B 2400 CLR R0
1C E6E0 LDI R30,0x60
1D E0F0 LDI R31,0
1E E010 LDI R17,0
1F 36E0 CPI R30,0x60
20 07F1 CPC R31,R17
21 F011 BEQ 0x0024
22 9201 ST R0,Z+
23 CFFB RJMP 0x001F
24 8300 STD Z+0,R16
25 E2E6 LDI R30,0x26
26 E0F0 LDI R31,0
27 E6A0 LDI R26,0x60
28 E0B0 LDI R27,0
29 E010 LDI R17,0
2A E000 LDI R16,0
2B BF0B OUT 0x3B,R16
2C 32E6 CPI R30,0x26
2D 07F1 CPC R31,R17
2E F021 BEQ 0x0033
2F 95C8 LPM
30 9631 ADIW R30,1
31 920D ST R0,X+
32 CFF9 RJMP 0x002C
33 D020 RCALL _main
_exit:
34 CFFF RJMP _exit
FILE: E:\xiaozhiyong2009\设计资料\项目设计\ICCAVR_mega8_C\ICCAVR_mega8_EEPROM读写\EEPROM读写.c
(0001) //ICC-AVR application builder : 2009-3-12 17:39:42
(0002) // Target : M8
(0003) // Crystal: 8.0000Mhz
(0004)
(0005) #include <iom8v.h>
(0006) #include <macros.h>
(0007)
(0008) void port_init(void)
(0009) {
(0010) PORTB = 0x00;
_port_init:
35 2422 CLR R2
36 BA28 OUT 0x18,R2
(0011) DDRB = 0x00;
37 BA27 OUT 0x17,R2
(0012) PORTC = 0x00; //m103 output only
38 BA25 OUT 0x15,R2
(0013) DDRC = 0x00;
39 BA24 OUT 0x14,R2
(0014) PORTD = 0x00;
3A BA22 OUT 0x12,R2
(0015) DDRD = 0x00;
3B BA21 OUT 0x11,R2
3C 9508 RET
(0016) }
(0017)
(0018) //call this routine to initialize all peripherals
(0019) void init_devices(void)
(0020) {
(0021) //stop errant interrupts until set up
(0022) CLI(); //disable all interrupts
_init_devices:
3D 94F8 BCLR 7
(0023) port_init();
3E DFF6 RCALL _port_init
(0024)
(0025) MCUCR = 0x00;
3F 2422 CLR R2
40 BE25 OUT 0x35,R2
(0026) GICR = 0x00;
41 BE2B OUT 0x3B,R2
(0027) TIMSK = 0x00; //timer interrupt sources
42 BE29 OUT 0x39,R2
(0028) SEI(); //re-enable interrupts
43 9478 BSET 7
44 9508 RET
(0029) //all peripherals are now initialized
(0030) }
(0031)
(0032) /*****************************************************************************
(0033) 用 途:EEPROM读写程序
(0034) Taget :mega8
(0035) crystal :8M
(0036) 介 绍:
(0037) *****************************************************************************/
(0038) //eeprom写操作
(0039) void eeprom_write(unsigned int address,unsigned char data)
(0040) {
(0041) while(EECR&(1<<EEWE))
_eeprom_write:
data --> R18
address --> R16
45 99E1 SBIC 0x1C,1
46 CFFE RJMP _eeprom_write
(0042) {;}
(0043) EEAR=address;
47 BB1F OUT 0x1F,R17
48 BB0E OUT 0x1E,R16
(0044) EEDR=data;
49 BB2D OUT 0x1D,R18
(0045) EECR|=(1<<EEMWE);
4A 9AE2 SBI 0x1C,2
(0046) EECR|=(1<<EEWE);
4B 9AE1 SBI 0x1C,1
4C 9508 RET
(0047) }
(0048) //eeprom读操作
(0049) unsigned char eeprom_read(unsigned int address)
(0050) {
(0051) while(EECR&(1<<EEWE))
_eeprom_read:
address --> R16
4D 99E1 SBIC 0x1C,1
4E CFFE RJMP _eeprom_read
(0052) {;}
(0053) EEAR=address;
4F BB1F OUT 0x1F,R17
50 BB0E OUT 0x1E,R16
(0054) EECR|=(1<<EERE);
51 9AE0 SBI 0x1C,0
(0055) return EEDR;
52 B30D IN R16,0x1D
53 9508 RET
(0056) }
(0057) //****************************************************************************
(0058) void main()
(0059) {
(0060) unsigned char i;
(0061) port_init();
_main:
i --> R10
54 DFE0 RCALL _port_init
(0062) init_devices();
55 DFE7 RCALL _init_devices
(0063)
(0064) eeprom_write(1,0x55);
56 E525 LDI R18,0x55
57 E001 LDI R16,1
58 E010 LDI R17,0
59 DFEB RCALL _eeprom_write
(0065) eeprom_write(2,0xAA);
5A EA2A LDI R18,0xAA
5B E002 LDI R16,2
5C E010 LDI R17,0
5D DFE7 RCALL _eeprom_write
(0066) i=eeprom_read(1);
5E E001 LDI R16,1
5F E010 LDI R17,0
60 DFEC RCALL _eeprom_read
(0067) PORTB=i;
61 BB08 OUT 0x18,R16
(0068) i=eeprom_read(2);
62 E002 LDI R16,2
63 E010 LDI R17,0
64 DFE8 RCALL _eeprom_read
65 2EA0 MOV R10,R16
(0069) PORTD=i;
66 BB02 OUT 0x12,R16
(0070) while(1)
FILE: <library>
67 CFFF RJMP 0x0067
68 9508 RET
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -