ata6616 ATMEL Corporation, ata6616 Datasheet - Page 248

no-image

ata6616

Manufacturer Part Number
ata6616
Description
Microcontroller With Lin Transceiver, 5v Regulator And Watchdog
Manufacturer
ATMEL Corporation
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
ata6616-P3QW
Manufacturer:
ATMEL
Quantity:
950
Part Number:
ata6616-P3QW
Manufacturer:
ATMEL/爱特梅尔
Quantity:
20 000
Part Number:
ata6616C
Manufacturer:
ATMEL/爱特梅尔
Quantity:
20 000
Part Number:
ata6616C-P3QW
Manufacturer:
ATMEL
Quantity:
887
4.21.2.7
248
ATA6616/ATA6617 [Preliminary]
Simple Assembly Code Example for a Boot Loader
Note that the RWWSB bit will always be read as zero in ATtiny167. Nevertheless, it is recom-
mended to check this bit as shown in the code example, to ensure compatibility with devices
supporting Read-While-Write.
.equ PAGESIZEB = PAGESIZE*2
.org SMALLBOOTSTART
Write_page:
Wrloop:
;- The routine writes one page of data from RAM to Flash
;
;
;- Error handling is not included
;- Registers used: r0, r1, temp1 (r16), temp2 (r17), looplo (r24),
;
; - Storing and restoring of registers is not included in the routine
;
; Page Erase
ldi
rcall Do_spm
; Clear temporary page buffer
ldi
rcall Do_spm
; Transfer data from RAM to Flash temporary page buffer
ldi
ldi
ld
ld
ldi
rcall Do_spm
adiw
sbiw
brne
; Execute Page Write
subi
sbci
ldi
rcall Do_spm
; Clear temporary page buffer
ldi
rcall Do_spm
; Read back and check, optional
ldi
ldi
subi
sbci
the first data location in RAM is pointed to by the Y-pointer
the first data location in Flash is pointed to by the Z-pointer
register usage can be optimized at the expense of code size
spmcsrval, (1<<PGERS) | (1<<SELFPGEN)
spmcsrval, (1<<CPTB) | (1<<SELFPGEN)
looplo, low(PAGESIZEB)
loophi, high(PAGESIZEB)
r0, Y+
r1, Y+
spmcsrval, (1<<SELFPGEN)
ZH:ZL, 2
loophi:looplo, 2
Wrloop
ZL, low(PAGESIZEB)
ZH, high(PAGESIZEB)
spmcsrval, (1<<PGWRT) | (1<<SELFPGEN)
spmcsrval, (1<<CPTB) | (1<<SELFPGEN)
looplo, low(PAGESIZEB)
loophi, high(PAGESIZEB)
YL, low(PAGESIZEB)
YH, high(PAGESIZEB)
loophi (r25), spmcsrval (r20)
; AGESIZEB is page size in BYTES, not words
; use subi for PAGESIZEB<=256
; restore pointer
; not required for PAGESIZEB<=256
; init loop variable
; not required for PAGESIZEB<=256
; restore pointer
; init loop variable
; not required for PAGESIZEB<=256
DRAFT
9132A–AUTO–10/08

Related parts for ata6616