;*F************************************************************************
**
; NAME: flash_read_sig
;--------------------------------------------------------------------------
--
; PARAMS:
; Return: R16: signature value
;--------------------------------------------------------------------------
--
; PURPOSE: Read harware signature byte. THe byte is selected trought the
addr
; passed as argument (see product data sheet)
;**************************************************************************
**
flash_read_sig:
RCALL WAIT_SPMEN ;Wait for SPMEN flag cleared
MOV
R31,R17
MOV
R30,R16
;move adress to z pointer (R31=ZH R30=ZL)
OUT
RAMPZ, R18
LDI
R20,$21
;(1<<SPMEN) | (1<<SIGRD))
OUT SPMCSR, R20; argument 2 decides function (r18)
LPM
;Store program memory
MOV
R16, R0
;Store return value (1byte->R16 register)
RJMP WAIT_SPMEN ;Wait for SPMEN flag cleared
;*F************************************************************************
**
; NAME: flash_read_fuse
;--------------------------------------------------------------------------
--
; Return: R16: fuse value
;--------------------------------------------------------------------------
--
; PURPOSE: Read fuse byte. The fuse byte is elected through the address
passed
; as argument (See product datasheet for addr value)
;**************************************************************************
**
flash_read_fuse:
RCALL WAIT_SPMEN ;Wait for SPMEN flag cleared
MOV
R31,R17
MOV
R30,R16
;move adress to z pointer (R31=ZH R30=ZL)
OUT
RAMPZ, R18
LDI
R20,$09
;(1<<SPMEN) | (1<<BLBSET))
OUT SPMCSR, R20; argument 2 decides function (r18)
LPM
;Store program memory
MOV
R16, R0
;Store return value (1byte->R16 register)
24
7618C–AVR–07/08