欢迎访问ic37.com |
会员登录 免费注册
发布采购

ATMEGA16M1-15MZ 参数 Datasheet PDF下载

ATMEGA16M1-15MZ图片预览
型号: ATMEGA16M1-15MZ
PDF下载: 下载PDF文件 查看货源
内容描述: [IC MCU 8BIT 16KB FLASH 32QFN]
分类和应用: 微控制器
文件页数/大小: 318 页 / 7595 K
品牌: MICROCHIP [ MICROCHIP ]
 浏览型号ATMEGA16M1-15MZ的Datasheet PDF文件第246页浏览型号ATMEGA16M1-15MZ的Datasheet PDF文件第247页浏览型号ATMEGA16M1-15MZ的Datasheet PDF文件第248页浏览型号ATMEGA16M1-15MZ的Datasheet PDF文件第249页浏览型号ATMEGA16M1-15MZ的Datasheet PDF文件第251页浏览型号ATMEGA16M1-15MZ的Datasheet PDF文件第252页浏览型号ATMEGA16M1-15MZ的Datasheet PDF文件第253页浏览型号ATMEGA16M1-15MZ的Datasheet PDF文件第254页  
24.7.13 Simple Assembly Code Example for a Boot Loader  
;-the routine writes one page of data from RAM to Flash  
; 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  
;-error handling is not included  
;-the routine must be placed inside the Boot space  
; (at least the Do_spm sub routine). Only code inside NRWW section can  
; be read during Self-Programming (Page Erase and Page Write).  
;-registers used: r0, r1, temp1 (r16), temp2 (r17), looplo (r24),  
; loophi (r25), spmcrval (r20)  
; storing and restoring of registers is not included in the routine  
; register usage can be optimized at the expense of code size  
;-It is assumed that either the interrupt table is moved to the Boot  
; loader section or that the interrupts are disabled.  
.equ  
.org  
PAGESIZEB = PAGESIZE*2  
SMALLBOOTSTART  
PAGESIZEB is page size in BYTES, not words  
Write_page:  
;
Page Erase  
ldi  
call  
spmcrval, (1<<PGERS) | (1<<SPMEN)  
Do_spm  
;
ldi  
call  
re-enable the RWW section  
spmcrval, (1<<RWWSRE) | (1<<SPMEN)  
Do_spm  
;
ldi  
ldi  
transfer data from RAM to Flash page buffer  
looplo, low(PAGESIZEB)  
loophi, high(PAGESIZEB)  
;init loop variable  
;not required for PAGESIZEB<=256  
Wrloop:  
ld  
r0, Y+  
ld  
r1, Y+  
ldi  
spmcrval, (1<<SPMEN)  
Do_spm  
ZH:ZL, 2  
loophi:looplo, 2  
Wrloop  
call  
adiw  
sbiw  
brne  
;use subi for PAGESIZEB<=256  
;
execute Page Write  
ZL, low(PAGESIZEB)  
ZH, high(PAGESIZEB)  
spmcrval, (1<<PGWRT) | (1<<SPMEN)  
Do_spm  
subi  
sbci  
ldi  
call  
;restore pointer  
;not required for PAGESIZEB<=256  
;
ldi  
call  
re-enable the RWW section  
spmcrval, (1<<RWWSRE) | (1<<SPMEN)  
Do_spm  
;
ldi  
ldi  
read back and check, optional  
looplo, low(PAGESIZEB)  
loophi, high(PAGESIZEB)  
YL, low(PAGESIZEB)  
;init loop variable  
;not required for PAGESIZEB<=256  
;restore pointer  
subi  
sbci  
Rdloop:  
lpm  
YH, high(PAGESIZEB)  
r0, Z+  
ld  
r1, Y+  
cpse  
jmp  
r0, r1  
Error  
sbiw  
brne  
loophi:looplo, 1  
Rdloop  
;use subi for PAGESIZEB<=256  
250  
ATmega16/32/64/M1/C1 [DATASHEET]  
7647O–AVR–01/15  
 复制成功!