📄 eeprom.s
字号:
.module EEPROM.c
.area text(rom, con, rel)
.dbfile E:\MYWORK~1\开发设计\EasyAVR\程序范例\Mega16程序包\完成整理\内部EEPROM实验\EEPROM.c
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 43
; /****************************************Copyright (c)**************************************************
; ** ADEmbed Development Co.,LTD.
; ** http://www.adembed.com
; **--------------File Info-------------------------------------------------------------------------------
; ** File name: EEPROM.c
; ** Last modified Date: 2008-12-13
; ** Last Version: 1.0
; ** Descriptions: IC inside EEPROM write and read test.
; **
; **------------------------------------------------------------------------------------------------------
; ** Created by: junbolu
; ** Created date: 2008-12-13
; ** Version: 1.0
; ** Descriptions:
; **
; **------------------------------------------------------------------------------------------------------
; ** Modified by:
; ** Modified date:
; ** Version:
; ** Descriptions:
; **
; **------------------------------------------------------------------------------------------------------
; **ICC-AVR application builder : 2008-12-13
; **Target : M16
; **Crystal: 7.3728Mhz
; **
; **
; **描述:这是一个读写片内EEPROM的测试程序。
; ** 没有一点多余的代码,清晰明了。
; **
; **涉及知识点:
; ** EEPROM
; **
; **
; *******************************************************************************************************/
; #include <iom16v.h>
; #include <macros.h>
; #include "define.h"
; #include "EEPROM.h"
;
;
; void main(void)
; {
.dbline 44
; EEPROM_write(0x01,0x66); //在地址0x01写入0x66
ldi R18,102
ldi R16,1
ldi R17,0
xcall _EEPROM_write
.dbline 45
; EEPROM_read(0x01); //读取地址0x01的数据
ldi R16,1
ldi R17,0
xcall _EEPROM_read
L2:
.dbline 46
L3:
.dbline 46
xjmp L2
X0:
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e EEPROM_write _EEPROM_write fV
; data -> R18
; address -> R16,R17
.even
_EEPROM_write::
.dbline -1
.dbline 51
; while(1);
; }
;
; //=======================================================================
; void EEPROM_write(uint16 address,uint8 data)
; {
.dbline 52
; SREG&=~0x80;
bclr 7
L6:
.dbline 54
.dbline 55
L7:
.dbline 53
; while(EECR&(1<<EEWE))
sbic 0x1c,1
rjmp L6
.dbline 56
; {
; }
; EEAR=address;
out 0x1f,R17
out 0x1e,R16
.dbline 57
; EEDR=data;
out 0x1d,R18
.dbline 58
; EECR|=(1<<EEMWE);
sbi 0x1c,2
.dbline 59
; EECR|=(1<<EEWE);
sbi 0x1c,1
.dbline 60
; SREG|=0x80;
bset 7
.dbline -2
L5:
.dbline 0 ; func end
ret
.dbsym r data 18 c
.dbsym r address 16 i
.dbend
.dbfunc e EEPROM_read _EEPROM_read fc
; address -> R16,R17
.even
_EEPROM_read::
.dbline -1
.dbline 65
; }
;
; //=======================================================================
; uint8 EEPROM_read(uint16 address)
; {
.dbline 66
; SREG&=~0x80;
bclr 7
L10:
.dbline 68
.dbline 69
L11:
.dbline 67
; while(EECR&(1<<EEWE))
sbic 0x1c,1
rjmp L10
.dbline 70
; {
; }
; EEAR=address;
out 0x1f,R17
out 0x1e,R16
.dbline 71
; EECR|=(1<<EERE);
sbi 0x1c,0
.dbline 72
; SREG|=0x80;
bset 7
.dbline 73
; return EEDR;
in R16,0x1d
.dbline -2
L9:
.dbline 0 ; func end
ret
.dbsym r address 16 i
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -