54
AT90PWM216/316 [DATASHEET]
7710H–AVR–07/2013
0xC03
out
SPL,r16
0xC04
sei
; Enable interrupts
0xC05
<instr>
xxx
When the BOOTRST Fuse is programmed, the Boot section size set to 2K bytes and the IVSEL bit in the MCUCR
Register is set before any interrupts are enabled, the most typical and general program setup for the Reset and
Interrupt Vector Addresses in AT90PWM216/316 is:
Address
Labels Code
Comments
;
.org 0xC00
0xC00
rjmp
RESET
; Reset handler
0xC01
rjmp
PSC2_CAPT
; PSC2 Capture event Handler
0xC02
rjmp
PSC2_EC
; PSC2 End Cycle Handler
...
;
0xC1F
rjmp
SPM_RDY
; Store Program Memory Ready Handler
;
0xC20
RESET: ldi
r16,high(RAMEND); Main program start
0xC21
out
SPH,r16
; Set Stack Pointer to top of RAM
0xC22
ldi
r16,low(RAMEND)
0xC23
out
SPL,r16
0xC24
sei
; Enable interrupts
0xC25
<instr>
xxx
9.1.1
Moving Interrupts Between Application and Boot Space
The MCU Control Register controls the placement of the Interrupt Vector table.
9.1.2
MCU Control Register – MCUCR
Bit 1 – IVSEL: Interrupt Vector Select
When the IVSEL bit is cleared (zero), the Interrupt Vectors are placed at the start of the Flash memory. When this
bit is set (one), the Interrupt Vectors are moved to the beginning of the Boot Loader section of the Flash. The actual
address of the start of the Boot Flash Section is determined by the BOOTSZ Fuses. Refer to the section
“BootInterrupt Vector tables, a special write procedure must be followed to change the IVSEL bit:
a.
Write the Interrupt Vector Change Enable (IVCE) bit to one.
b.
Within four cycles, write the desired value to IVSEL while writing a zero to IVCE.
Interrupts will automatically be disabled while this sequence is executed. Interrupts are disabled in the cycle IVCE
is set, and they remain disabled until after the instruction following the write to IVSEL. If IVSEL is not written, inter-
rupts remain disabled for four cycles. The I-bit in the Status Register is unaffected by the automatic disabling.
Note:
If Interrupt Vectors are placed in the Boot Loader section and Boot Lock bit BLB02 is programmed, interrupts are dis-
abled while executing from the Application section. If Interrupt Vectors are placed in the Application section and Boot
Lock bit BLB12 is programed, interrupts are disabled while executing from the Boot Loader section. Refer to the sec-
Bit
7
65432
10
SPIPS
–
PUD
–
IVSEL
IVCE
MCUCR
Read/Write
R/W
R
R/W
R
R/W
Initial Value
0
00000
00