| ??? 07/25/02 09:21 Read: times |
#26298 - RE: how to access internal eeprom of at8282 |
The functions declaration in main.h
void WrRom(void); void RdRom(void); The variable for access to EEPROM declaration in main.c data unsigned char addr; data unsigned long var; Example of use of functions addr = 0; var = 123; WrRom(); addr = 0; RdRom(); a = var; Actually functions accordingly in files rdrom.asm and wrrom.asm These files need to be included in the project. Where 'abc' is a name of your project ?PR?RdRom?abc SEGMENT CODE EXTRN DATA (addr) EXTRN DATA (var) EXTRN CODE (?C_STARTUP) PUBLIC RdRom RSEG ?PR?RdRom?abc USING 0 ;Reading 4 bytes (for example, UNSIGNED LONG) from EEPROM AT89S8252 ; ;addr - address EEPROM (is always multiple to four) ;var - variable in which the read value is located WMCON EQU 96h RdRom: mov WMCON, #08h mov DPH, #00h mov r0, #addr mov a, @r0 mov DPL, a mov r0, #var movx a, @dptr mov @r0, a inc dptr inc r0 movx a, @dptr mov @r0, a inc dptr inc r0 movx a, @dptr mov @r0, a inc dptr inc r0 movx a, @dptr mov @r0, a mov WMCON, #00h ret end ?PR?WrRom?abc SEGMENT CODE EXTRN DATA (addr) EXTRN DATA (var) EXTRN CODE (?C_STARTUP) PUBLIC WrRom RSEG ?PR?WrRom?abc USING 0 ;Writing 4 bytes (for example, UNSIGNED LONG) into EEPROM AT89S8252 ; ;addr - address EEPROM (is always multiple to four) ;var - ariable which will be written down in EEPROM WMCON EQU 96h WrRom: mov WMCON, #18h mov DPH, #00h mov r0, #addr mov a, @r0 mov DPL, a mov r0, #var wait0: mov b, WMCON jnb b.1, wait0 mov a, @r0 movx @dptr, a wait1: mov b, WMCON jnb b.1, wait1 inc dptr inc r0 mov a, @r0 movx @dptr, a wait2: mov b, WMCON jnb b.1, wait2 inc dptr inc r0 mov a, @r0 movx @dptr, a wait3: mov b, WMCON jnb b.1, wait3 inc dptr inc r0 mov a, @r0 movx @dptr, a wait4: mov b, WMCON jnb b.1, wait4 mov WMCON, #00h ret end |
| Topic | Author | Date |
| how to access internal eeprom of at8282 | 01/01/70 00:00 | |
RE: how to access internal eeprom of at8282 | 01/01/70 00:00 |



