⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e2prom_1.lis

📁 Application Note Abstract This Application Note introduces a complete and detailed PSoC&reg project
💻 LIS
字号:
 0000           ;------------------------------------------------------------------------------
 0000           ;  FILENAME:   E2PROM_1.asm
 0000           ;  VERSION:   Rev A, 2002 JUL 25
 0000           ;------------------------------------------------------------------------------
 0000           ;  DESCRIPTION:
 0000           ;     Routines in this file perform E2PROM_1 User Module Read and 
 0000           ;     Write operations.
 0000           ;
 0000           ;     They provide a layer of abstraction on top of the E2PROMLIB.asm routines
 0000           ;     to allow instancing of the EEPROM devices.  Together the E2PROM and
 0000           ;     E2PROMLIB algorithms emulate a byte-wise EEPROM device on a block oriented
 0000           ;     flash architecture.
 0000           ;------------------------------------------------------------------------------
 0000           ;  Copyright (c) Cypress MicroSystems 2000-2002. All rights reserved.
 0000           ;------------------------------------------------------------------------------
 0000           
                export   E2PROM_1_bE2Write
                export  _E2PROM_1_bE2Write
                export   E2PROM_1_E2Read
                export  _E2PROM_1_E2Read
                
                export   E2PROM_1_RESERVED
                
                ;--------------------------------
                ;  Includes
                ;--------------------------------
 0000           E2_WR_ARG_cTemperature:          equ      0        ; chip temperature
 0001           E2_WR_ARG_wByteCount:            equ      1        ; Byte Count to Write
 0003           E2_WR_ARG_pbData:                equ      3        ; Data buffer with data to write
 0005           E2_WR_ARG_wAddr:                 equ      5        ; Address offset in E2PROM to write
 0007           E2_WR_ARG_STACK_FRAME_SIZE:      equ      7        ; SIZE of the argument list in stack frame
 0007           E2_CALLER_RETURN_ADDRESS:        equ      7        ; callers return address - place holder
 0000           
 0000           ;-------------------------------------
 0000           ;  Return Values
 0000           ;-------------------------------------
 0000           NOERROR:                         equ      0        ; Successfull completion
 FFFFFFFF           FAILURE:                         equ     -1        ; Error condition
 FFFFFFFE           STACKOVERFLOW:                   equ     -2        ; Error Stack Overflow
 0000           
 0000           
 0000           
 0000           ;-----------------------------------------------------------------------------
 0000           ;  FUNCTION NAME: E2Read
 0000           ;
 0000           ;  DESCRIPTION:
 0000           ;     Reads the specified E2PROM data at offset=wAddr for wByteCount bytes  and
 0000           ;     places the data read into the RAM buffer pbDataDest.
 0000           ;
 0000           ;     On entry - NOTE two entry points!!!
 0000           ;           A must contain the E2PROM device First block Id
 0000           ;           X must point to calling arguments in the following offset from X:
 0000           ;              wByteCount  0  2-bytes
 0000           ;              pbDataDest  2  2-bytes
 0000           ;              wAddr:      4  2-bytes
 0000           ;
 0000           ;     Prototype in C is:
 0000           ;
 0000           ;        #pragma  fastcall E2Read
 0000           ;        void E2Read( BYTE bFirstBlockId, WORD wAddr, BYTE * pbDataDest, WORD wByteCount );
 0000           ;
 0000           ;           (!!!note that C places arguments Right-to-Left onto the stack!!!)
 0000           ;
 0000           ;     Easiest method to call from assembly is as follows:
 0000           ;           push  X
 0000           ;           mov   X, SP
 0000           ;           push  <wByteCount>
 0000           ;           push  <wByteCount+1>
 0000           ;           push  <0>                  ; MSB of pbDataDest is always 0 
 0000           ;           push  <pbDataDest>
 0000           ;           push  <wAddr>
 0000           ;           push  <wAddr+1>
 0000           ;           mov   A, <FirstBlockId>
 0000           ;           call  E2Read
 0000           ;           add   SP, -E2_RD_ARG_STACK_FRAME_SIZE 
 0000           ;           pop   X
 0000           ;
 0000           ;           where <> refers to any addressing mode or number of instructions to
 0000           ;              place the referenced data on the stack frame.
 0000           ;
 0000           ;           Other method is to create a stack frame using the defined equates and 
 0000           ;           load them into the stack frame using [X+E2_RD_ARG_*] offset addressing mode.
 0000           ;
 0000           ;  ARGUMENTS:
 0000           ;     
 0000           ;     bFirstBlockId  BYTE   - first block ID of E2PROM device
 0000           ;     wAddr:         WORD   - relative OFFSET in defined E2PROM to read data
 0000           ;     pbDataDest:    BYTE * - pointer to the RAM buffer to place read data
 0000           ;     wByteCount:    WORD   - number of bytes to read from E2PROM
 0000           ;
 0000           ;  RETURNS:       NONE.
 0000           ;
 0000           ;  SIDE EFFECTS:  NONE.
 0000           ;
 0000           ;-----------------------------------------------------------------------------
 0000           E2_RD_ARG_wByteCount:         equ      0           ; Byte Count to Read
 0002           E2_RD_ARG_pbDataDest:         equ      2           ; Data buffer to store read data
 0004           E2_RD_ARG_wAddr:              equ      4           ; Address offset in E2PROM to Read
 0006           E2_RD_ARG_STACK_FRAME_SIZE:   equ      6           ; SIZE of argument list in stack frame
 0000           
 0000           ;--------------------
 0000           ;  End of File
 0000           ;--------------------
 0000           
 0000           ;----------------------------------------
 0000           ;  E2PROM_1 instance parameters
 0000           ;----------------------------------------
 0040           E2PROM_1_START_BLOCK:            equ      40h                        ; Absolute address of E2PROM device    
 1000           E2PROM_1_START_ADDR:             equ      40h * 64                   ; Size of E2PROM device
 0000                        
 0000           ;-------------------------------------
 0000           ;  Return Values
 0000           ;-------------------------------------
 0000           NOERROR:                         equ      0                          ; Successfull completion
 FFFFFFFF           FAILURE:                         equ     -1                          ; Error condition
 FFFFFFFE           STACKOVERFLOW:                   equ     -2                          ; Error Stack Overflow
 0000           
 0000           
 0000           ; end of E2PROM_1.inc
 0000           
 0000           ;-----------------------------------------------------------------
 0000           ;  Allocate the E2PROM_1 EEPROM device in Flash memory
 0000           ;     This will allow the linker to perform memory collision 
 0000           ;     checking and the EEPROM device will be displayed in the 
 0000           ;     map file.  
 0000           ;     Note that this memory region can also be accessed from "C".
 0000           ;-----------------------------------------------------------------
                AREA  E2PROM_1_AREA   (ROM,ABS)
                   ORG   E2PROM_1_START_ADDR
 1000           _E2PROM_1_RESERVED::
 1000            E2PROM_1_RESERVED::     blkb     40h
 1040           
 1040           
                AREA  text (ROM,REL)
                
                ;------------------------------------------------------------------------------
                ;  FUNCTION NAME: E2Write
                ;
                ;  DESCRIPTION:
                ;     Writes the specified E2PROM data at the wAddr and wByteCount from RAM into 
                ;     Flash into the defined E2PROM.
                ;
                ;     On entry - NOTE two entry points!!!
                ;           X must point to calling arguments in the following offset from X:
                ;              wAddr:         5  2-bytes
                ;              pbData:        3  2-bytes
                ;              wByteCount:    1  2-bytes
                ;              cTemperature:  0  1-byte
                ;
                ;     Prototype in C is:
                ;
                ;        #pragma  fastcall E2Write
                ;        void E2PROM_1_bE2Write( WORD wAddr, BYTE * pbData, WORD wByteCount, 
                ;                                        CHAR cTermperature );
                ;
                ;           (!!!note that C places arguments Right-to-Left onto the stack!!!)
                ;
                ;     Easiest method to call from assembly is as follows:
                ;           push  X
                ;           mov   X, SP
                ;           push  <cTemperature>
                ;           push  <wByteCount>
                ;           push  <wByteCount+1>
                ;           push  <0>                  ; MSB of pbDataDest is always 0 
                ;           push  <pbDataDest>
                ;           push  <wAddr>
                ;           push  <wAddr+1>
                ;           call  E2PROM_1_bE2Write
                ;           add   SP, -E2_RD_ARG_STACK_FRAME_SIZE 
                ;           pop   X
                ;
                ;           where <> refers to any addressing mode or number of instructions to
                ;              place the referenced data on the stack frame.
                ;
                ;           Other method is to create a stack frame using the defined equates and 
                ;           load them into the stack frame using [X+E2_WR_ARG_*] offset addressing mode.
                ;
                ;  ARGUMENTS:
                ;     
                ;     wAddr:         WORD   - relative OFFSET in defined E2PROM to write data
                ;     pbData:        BYTE * - pointer to the RAM buffer of data to write
                ;     wByteCount:    WORD   - number of bytes to write into E2PROM
                ;     cTemperature:  CHAR   - temperature in degrees celsius
                ;
                ;  RETURNS:    NOERROR, FAILURE, or STACKOVERFLOW
                ;
                ;  SIDE EFFECTS:  If a partial block is to be saved to flash, then a 64 byte buffer
                ;                 is temporary allocated.
                ;
                ;  PROCEDURE:  
                ;     1) Place the Starting Block ID into the accumulator 
                ;     2) Jump to the bE2Write algorithm in the E2PROMLIB
                ;------------------------------------------------------------------------------
                ;------------------
                ; Assembly Entry
                ;------------------
 0000            E2PROM_1_bE2Write::
 0000 5040         mov   A, E2PROM_1_START_BLOCK
 0002 7D0000       ljmp  bE2Write
 0005           
 0005           ;------------------
 0005           ; 'C' Entry
 0005           ;------------------
 0005           _E2PROM_1_bE2Write::
 0005 5040         mov   A, E2PROM_1_START_BLOCK
 0007 7D0000       ljmp  _bE2Write
 000A           
 000A           
 000A           ;-----------------------------------------------------------------------------
 000A           ;  FUNCTION NAME: E2Read
 000A           ;
 000A           ;  DESCRIPTION:
 000A           ;     Reads the specified E2PROM data at offset=wAddr for wByteCount bytes  and
 000A           ;     places the data read into the RAM buffer pbDataDest.
 000A           ;
 000A           ;     On entry - NOTE two entry points!!!
 000A           ;           X must point to calling arguments in the following offset from X:
 000A           ;              wByteCount  0  2-bytes
 000A           ;              pbDataDest  2  2-bytes
 000A           ;              wAddr:      4  2-bytes
 000A           ;
 000A           ;     Prototype in C is:
 000A           ;
 000A           ;        #pragma  fastcall E2Read
 000A           ;        void E2PROM_1_E2Read( WORD wAddr, BYTE * pbDataDest, WORD wByteCount );
 000A           ;
 000A           ;           (!!!note that C places arguments Right-to-Left onto the stack!!!)
 000A           ;
 000A           ;     Easiest method to call from assembly is as follows:
 000A           ;           push  X
 000A           ;           mov   X, SP
 000A           ;           push  <wByteCount>
 000A           ;           push  <wByteCount+1>
 000A           ;           push  <0>                  ; MSB of pbDataDest is always 0 
 000A           ;           push  <pbDataDest>
 000A           ;           push  <wAddr>
 000A           ;           push  <wAddr+1>
 000A           ;           call  E2PROM_1_E2Read
 000A           ;           add   SP, -E2_RD_ARG_STACK_FRAME_SIZE 
 000A           ;           pop   X
 000A           ;
 000A           ;           where <> refers to any addressing mode or number of instructions to
 000A           ;              place the referenced data on the stack frame.
 000A           ;
 000A           ;           Other method is to create a stack frame using the defined equates and 
 000A           ;           load them into the stack frame using [X+E2_RD_ARG_*] offset addressing mode.
 000A           ;
 000A           ;  ARGUMENTS:
 000A           ;     
 000A           ;     bFirstBlockId  BYTE   - first block ID of E2PROM device
 000A           ;     wAddr:         WORD   - relative OFFSET in defined E2PROM to read data
 000A           ;     pbDataDest:    BYTE * - pointer to the RAM buffer to place read data
 000A           ;     wByteCount:    WORD   - number of bytes to read from E2PROM
 000A           ;
 000A           ;  RETURNS:       NONE.
 000A           ;
 000A           ;  SIDE EFFECTS:  NONE.
 000A           ;
 000A           ;  PROCEDURE:     
 000A           ;     1) Place the Starting Block ID into the accumulator 
 000A           ;     2) Jump to the bE2Write algorithm in the E2PROMLIB
 000A           ;-----------------------------------------------------------------------------
 000A           ;------------------
 000A           ; Assembly Entry
 000A           ;------------------
 000A            E2PROM_1_E2Read::
 000A 5040         mov   A, E2PROM_1_START_BLOCK
 000C 7D0000       ljmp  E2Read
 000F           
 000F           ;------------------
 000F           ; 'C' Entry
 000F           ;------------------
 000F           _E2PROM_1_E2Read::
 000F 5040         mov   A, E2PROM_1_START_BLOCK
 0011 7D0000       ljmp  _E2Read
 0014              
 0014           
 0014           ; End of File   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -