atmega323l ATMEL Corporation, atmega323l Datasheet - Page 185
![no-image](/images/manufacturer_photos/0/0/79/atmel_corporation_sml.jpg)
atmega323l
Manufacturer Part Number
atmega323l
Description
Atmega323 8-bit Avr Microcontroller With 32k Bytes Of In-system Programmable Flash
Manufacturer
ATMEL Corporation
Datasheet
1.ATMEGA323L.pdf
(247 pages)
- Current page: 185 of 247
- Download datasheet (4Mb)
Assembly code example for a
Boot Loader
1457G–AVR–09/03
;- the routine writes one page of data from RAM to Flash the first data
: location in RAM is pointed to by the Y pointer (lowest address) the first
; data location in Flash is pointed to by the Z-pointer (lowest address)
; - error handling is not included – the routine must be placed inside the
; boot space. Only code inside boot loader section should be read during
; self-programming.
;- registers used: r0, r1, temp1, temp2, looplo, loophi, spmcrval storing and
; restoring of registers is not included in the routine
;
;- It is assumed that the interrupts are disabled
.equ PAGESIZEB = PAGESIZE*2
.org SMALLBOOTSTART
Write_page:
; page erase
Wrloop:
Rdloop:
Return:
; re-enable the Application Section
; transfer data from RAM to Flash page buffer
; execute page write
; re-enable the Application Section
; read back and check, optional
; return to Application Section
; verify that Application Section is safe to read
; re-enable the Applicaiton Section
register usage can be optimized at the expense of code size
ldi
call Do_spm
ldi
call Do_spm
ldi
ldi
ld
ld
ldi
call Do_spm
adiw ZH:ZL, 2
sbiw loophi:looplo, 2
brne Wrloop
subi ZL, low(PAGESIZEB)
sbci ZH, high(PAGESIZEB)
ldi
call Do_spm
ldi
call Do_spm
ldi
ldi
subi YL, low(PAGESIZEB)
sbci YH, high(PAGESIZEB)
lpm
ld
cpse r0, r1
jmp
sbiw loophi:looplo, 2
brne Rdloop
in
sbrs temp1, ASB
ret
ldi
spmcrval, (1<<PGERS) + (1<<SPMEN)
spmcrval, (1<<ASRE) + (1<<SPMEN)
looplo, low(PAGESIZEB) ;init loop variable
loophi, high(PAGESIZEB);not required for PAGESIZEB<=256
r0, Y+
r1, Y+
spmcrval, (1<<SPMEN)
spmcrval, (1<<PGWRT) + (1<<SPMEN)
spmcrval, (1<<ASRE) + (1<<SPMEN)
looplo, low(PAGESIZEB) ;init loop variable
loophi, high(PAGESIZEB);not required for PAGESIZEB<=256
r0, Z+
r1, Y+
Error
temp1, SPMCR
spmcrval, (1<<ASRE) + (1<<SPMEN)
;PAGESIZEB is page size in BYTES, not words
;use subi for PAGESIZEB<=256
;restore pointer
;not required for PAGESIZEB<=256
;restore pointer
;use subi for PAGESIZEB<=256
; If ASB is set, the AS is not ready yet
ATmega323(L)
185
Related parts for atmega323l
Image
Part Number
Description
Manufacturer
Datasheet
Request
R
![U641B](/images/manufacturer_photos/0/0/79/atmel_corporation_tmb.jpg)
Part Number:
Description:
INTERVAL AND WIPE/WASH WIPER CONTROL IC WITH DELAY
Manufacturer:
ATMEL Corporation
Datasheet:
![U4082B](/images/manufacturer_photos/0/0/79/atmel_corporation_tmb.jpg)
Part Number:
Description:
Low-Voltage Voice-Switched IC for Hands-Free Operation
Manufacturer:
ATMEL Corporation
Datasheet:
![U4089B](/images/manufacturer_photos/0/0/79/atmel_corporation_tmb.jpg)
Part Number:
Description:
MONOLITHIC INTEGRATED FEATUREPHONE CIRCUIT
Manufacturer:
ATMEL Corporation
Datasheet:
![U4255BM-M](/images/manufacturer_photos/0/0/79/atmel_corporation_tmb.jpg)
Part Number:
Description:
AM-FM Receiver IC U4255BM-M
Manufacturer:
ATMEL Corporation
Datasheet:
![U4089B-P](/images/manufacturer_photos/0/0/79/atmel_corporation_tmb.jpg)
Part Number:
Description:
Monolithic Integrated Feature Phone Circuit
Manufacturer:
ATMEL Corporation
Datasheet:
![TDA4470](/images/manufacturer_photos/0/0/79/atmel_corporation_tmb.jpg)
Part Number:
Description:
Multistandard Video-IF and Quasi Parallel Sound Processing
Manufacturer:
ATMEL Corporation
Datasheet:
![ATF22V10B-25PC](/images/manufacturer_photos/0/0/79/atmel_corporation_tmb.jpg)
Part Number:
Description:
High-performance EE PLD
Manufacturer:
ATMEL Corporation
Datasheet:
![AT89C51ED2-IM](/images/manufacturer_photos/0/0/79/atmel_corporation_tmb.jpg)
Part Number:
Description:
8-bit Flash Microcontroller
Manufacturer:
ATMEL Corporation
Datasheet:
![AT24C01](/images/manufacturer_photos/0/0/79/atmel_corporation_tmb.jpg)
Part Number:
Description:
2-Wire Serial EEPROM
Manufacturer:
ATMEL Corporation
Datasheet:
![U6046B](/images/manufacturer_photos/0/0/79/atmel_corporation_tmb.jpg)
Part Number:
Description:
U6046BREAR WINDOW HEATING TIMER / LONG-TERM TIMER
Manufacturer:
ATMEL Corporation
Datasheet: