编辑: 旋风 2013-04-29

PA set as output mode SET PAPU MOV A,0AH MOV WDTC,A ;

close WDT CLR EMI ;

Close Global interrupt SET HLCLK ;

System clock selection forHXT CLR ACERL CLR CP0C Rev. 1.10

2 2012-1-31 HT67Fx0 Data EEPROM 的使用方法与注意事项 CLR CP1C ;

Set as the I/O mode ;

EEPROM WRITE OPERATION WRITE_EEPROM: MOV A,10H MOV EEPROM_ADRES,A ;

Set write data address MOV A,055H MOV EEPROM_DATA,A ;

Set write data value MO A,EEPROM_ADRES MOV EEA,A MOV A,EEPROM_DATA MOV EED,A SET BP.0 ;

setup Bank Pointer MOV A,40H ;

setup memory pointer MP1 MOV MP1,A ;

MP1 points to EEC register SET IAR1.3 ;

set WREN bit, enable write operations SET IAR1.2 ;

start Write Cycle - set WR bit WRITE_WAIT: SZ IAR1.2 ;

check for write cycle end JMP WRITE_WAIT CLR IAR1 ;

disable EEPROM read/write CLR BP ;

EEPROM READ OPEATION READ_EEPROM: MOV A,10H MOV EEPROM_ADRES,A ;

Set write data address MOV A,EEPROM_ADRES MOV EEA,A SET BP.0 ;

setup Bank Pointer MOV A,40H ;

setup memory pointer MP1 MOV MP1,A ;

MP1 points to EEC register SET IAR1.1 ;

set RDEN bit, enable read operations SET IAR1.0 ;

start Read Cycle - set RD bit READ_WAIT: SZ IAR1.0 ;

check for read cycle end JMP READ_WAIT MOV A,EED ;

move read data to register XOR A,EEPROM_DATA ;

Read out value compared to the value written SZ ACC ;

Determine the consistency of read data and write data JMP FAIL MOV A,01H XORM A,PA ;

If the same then PA0 output waveform JMP WRITE_EEPROM FAIL: MOV A,02H XORM A,PA ;

If the inconsistency then PA1 output waveform JMP FAIL Rev. 1.10

3 2012-1-31 HT67Fx0 Data EEPROM 的使用方法与注意事项 程序说明 本范例主要介绍如何通过查询标志,以及正确设定相关寄存器来实现对 EEPROM 的读取/ 写入操作,在范例上只是简单的循环写入和读取 EEPROM 的一个字节的内容,其执行过程 是对 EEPROM 的[10H]写入 55H 后,再从 EEPROM 的[10H]读取出来与写入的值相比较, 如果正确即 PA0 输出波形,反之 PA1 输出波形.通过示波器观察

2 个I/O 口的输出就可以 判断对 EEPROM 的读取/写入操作是否正常. 用户使用时,只要调用下面读取/写入操作的子程序模块 (完成一个指定地址的读取和写 入),即可完成单字节的读取/写入操作,如需要读取/写入多个字节的内容时,只需在调用 此子程序的同时修改所需要写入和读取时的地址变量 EEPROM_ADRES 和数据变量 EEPROM_DATA 就可以进行多字节操作.读取/写入操作子程序如下: 读取操作模块: READ_EEPROM_LOOP: MOV A,EEPROM_ADRES MOV EEA,A SET BP.0 ;

setup Bank Pointer MOV A,40H ;

setup memory pointer MP1 MOV MP1,A ;

MP1 points to EEC register SET IAR1.1 ;

set RDEN bit, enable read operations SET IAR1.0 ;

start Read Cycle - set RD bit READ_WAIT: SZ IAR1.0 ;

check for read cycle end JMP READ_WAIT CLR IAR ;

disable EEPROM read/write CLR BP RET 写操作模块: WRITE_EEPROM_LOOP: MOV A,EEPROM_ADRES MOV EEA,A MOV A,EEPROM_DATA MOV EED,A SET BP.0 ;

setup Bank Pointer MOV A,40H ;

setup memory pointer MP1 MOV MP1,A ;

MP1 points to EEC register SET IAR1.3 ;

set WREN bit, enable write operations SET IAR1.2 ;

start Write Cycle - set WR bit WRITE_WAIT: SZ IAR1.2 ;

check for write cycle end JMP WRITE_WAIT CLR IAR1 ;

disable EEPROM read/write CLR BP RET Rev. 1.10

4 2012-1-31 HT67Fx0 Data EEPROM 的使用方法与注意事项 范例<

2>

:以中断的方式完成对EEPROM的写入操作 ;

程序名:EEPROM 写入模式中断 (eeprom_r_int.asm) ;

目的:完成对 EEPROM 写入操作后进入中断服务程序. ;

下载(注:源文件不在本站服务器,都将跳转到源网站下载)
备用下载
发帖评论
相关话题
发布一个新话题