Rainbow-electronics ATmega163L Manual do Utilizador Página 122

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 156
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 121
ATmega163(L)
122
ldi spmcrval, (1<<ASRE) + (1<<SPMEN)
call Do_spm
; transfer data from RAM to Flash page buffer
ldi looplo, low(PAGESIZEB) ;init loop variable
ldi loophi, high(PAGESIZEB) ;not required for PAGESIZEB<=256
Wrloop:
ld r0, Y+
ld r1, Y+
ldi spmcrval, (1<<SPMEN)
call Do_spm
adiw ZH:ZL, 2
sbiw loophi:looplo, 2 ;use subi for PAGESIZEB<=256
brne Wrloop
; execute page write
subi ZL, low(PAGESIZEB) ;restore pointer
sbci ZH, high(PAGESIZEB) ;not required for PAGESIZEB<=256
ldi spmcrval, (1<<PGWRT) + (1<<SPMEN)
call Do_spm
; re-enable the Application Section
ldi spmcrval, (1<<ASRE) + (1<<SPMEN)
call Do_spm
; read back and check, optional
ldi looplo, low(PAGESIZEB) ;init loop variable
ldi loophi, high(PAGESIZEB) ;not required for PAGESIZEB<=256
subi YL, low(PAGESIZEB) ;restore pointer
sbci YH, high(PAGESIZEB)
Rdloop:
lpm r0, Z+
ld r1, Y+
cpse r0, r1
jmp Error
sbiw loophi:looplo, 2 ;use subi for PAGESIZEB<=256
brne Rdloop
; return to Application Section
; verify that Application Section is safe to read
Return:
in temp1, SPMCR
sbrs temp1, ASB ; If ASB is set, the AS is not ready yet
ret
; re-enable the Applicaiton Section
ldi spmcrval, (1<<ASRE) + (1<<SPMEN)
call Do_spm
rjmp Return
Do_spm:
; input: spmcrval determines SPM action
; check that no EEPROM write access is running
Wait_ee:
sbic EECR, EEWE
rjmp Wait_ee
; SPM timed sequence
out SPMCR, spmcrval
spm
.dw $FFFF ; ensure proper pipelining
nop ; of next instruction
; check for SPM complete
Wait_spm:
in temp1, SPMCR
sbrc temp1, SPMEN
Vista de página 121
1 2 ... 117 118 119 120 121 122 123 124 125 126 127 ... 155 156

Comentários a estes Manuais

Sem comentários