attiny167-esxz ATMEL Corporation, attiny167-esxz Datasheet - Page 214
attiny167-esxz
Manufacturer Part Number
attiny167-esxz
Description
8-bit Avr 8-bit Microcontroller Microcontroller With 16k Bytes In-system Programmable Flash And Lin Controller
Manufacturer
ATMEL Corporation
Datasheet
1.ATTINY167-ESXZ.pdf
(277 pages)
- Current page: 214 of 277
- Download datasheet (4Mb)
20.2.7
214
ATtiny167
Simple Assembly Code Example for a Boot Loader
Note that the RWWSB bit will always be read as zero in ATtiny167. Nevertheless, it is
recommended 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:
Rdloop:
;- 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
lpm
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)
r0, Z+
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
7728A–AUTO–07/08
Related parts for attiny167-esxz
Image
Part Number
Description
Manufacturer
Datasheet
Request
R
Part Number:
Description:
Manufacturer:
Atmel Corporation
Datasheet:
Part Number:
Description:
Manufacturer:
Atmel Corporation
Datasheet:
Part Number:
Description:
IC, MCU, 8BIT, 2K FLASH, 20SOIC
Manufacturer:
Atmel
Datasheet:
Part Number:
Description:
IC, MCU, 8BIT, 2K FLASH, 20PDIP
Manufacturer:
Atmel
Datasheet:
Part Number:
Description:
IC, MCU, 8BIT, 8K FLASH, 20PDIP
Manufacturer:
Atmel
Datasheet:
Part Number:
Description:
IC, MCU, 8BIT, 8K FLASH, 20SOIC
Manufacturer:
Atmel
Datasheet:
Part Number:
Description:
INTERVAL AND WIPE/WASH WIPER CONTROL IC WITH DELAY
Manufacturer:
ATMEL Corporation
Datasheet:
Part Number:
Description:
Low-Voltage Voice-Switched IC for Hands-Free Operation
Manufacturer:
ATMEL Corporation
Datasheet:
Part Number:
Description:
MONOLITHIC INTEGRATED FEATUREPHONE CIRCUIT
Manufacturer:
ATMEL Corporation
Datasheet:
Part Number:
Description:
AM-FM Receiver IC U4255BM-M
Manufacturer:
ATMEL Corporation
Datasheet:
Part Number:
Description:
Monolithic Integrated Feature Phone Circuit
Manufacturer:
ATMEL Corporation
Datasheet:
Part Number:
Description:
Multistandard Video-IF and Quasi Parallel Sound Processing
Manufacturer:
ATMEL Corporation
Datasheet: