HT46F46E/HT46F47E/HT46F48E/HT46F49E
The following program example shows how to initialise the EEPROM after power-on:
mov
mov
mov
mov
Call
mov
mov
mov
mov
call
A,01h
BP,A
A,40h
MP1,A
EWEN
A, 7Fh
EEADDR, A
A, 55h
EEDATA, A
WRITE
; set to bank 1
; set MP1 to EECR address
; subroutine to run EWEN instructions
; subroutine to run WRITE instruction
; write 55h data to address 7Fh
; optional subroutine to run EWDS instruction
call
EWDS
EEPROM Program Examples
The following short programs gives examples of how to send instructions, read and write to the EEPROM. These pro-
grams can form a basis of understanding as to how the internal EEPROM memory is to be used to store and retrieve
data. The programs are for use with the HT46F49E device, which has the same capacity internal EEPROM memory of
256´8 bits. For the other devices, which have a smaller 128´8 bit EEPROM memory capacity, the dummy bit which is
inserted between the instruction code transmission and the address MSB, is not transmitted.
Example 1 - Definitions and Sending Instructions to the EEPROM
_CS EQU IAR1.4
_SK EQU IAR1.5
_DI EQU IAR1.6
_DO EQU IAR1.7
; EEPROM lines setup to have a corresponding
; Bit in the Indirect Addressing Register IAR1
; EEPROM can only be indirectly addressed using MP1
_EECR
EQU
40H
; Setup address of the EEPROM control register
; Address length - 8-bits for this device
; Data length - always 8-bits
C_Addr_Length EQU 8
C_Data_Length EQU 8
;
DATA .SECTION at 70h ¢DATA¢
EE_command DB
?
?
?
?
; Stores the read or write instruction information
; Store write data or read data address
; Store read or write data
ADDR
WR_Data
COUNT
;
DB
DB
DB
; Temporary counter
WriteCommand:
MOV A,3
; Write instruction code subroutine
; Read, write and erase instructions are 3 bits long
MOV COUNT,A
WriteCommand_0:
CLR _DI
; Prepare the transmitted bit
; Check value of highest instruction code bit
SZ
EE_command.7
SET _DI
SET _SK
CLR _SK
CLR
C
RLC EE_command
SDZ COUNT
; Get next bit of instruction code
; Check if last bit has been transmitted
JMP WriteCommand_0
CLR _DI
RET
Rev. 1.40
25
July 28, 2009