; Автор:	shilow@ukr.net
; Дата:
; Название:
; Версия:
; Имя файла:
; Для AVR:	ATmega64
; Тактовая частота:
; Выполняемые функции:
;
;

;******************************
.listmac	; развернём макросы
; инклуды
.nolist
.include "m64def.inc"
.list

;******************************
; опредления
.def temp = r16		; рабочая переменная

;******************************
; константы
.equ a = 0		; sample

;******************************
; ячейки в СОЗУ, 4KB
.DSEG
;.ORG	SRAM_START
Sample:	.byte	30

;******************************
; константы в EEPROM, 2KB
.ESEG
smpl1:	.DW	0x0000	; sample 1
smpl2:	.DB	0x05	; sample 2

;******************************
; память программ, 64KB
.CSEG
.ORG 0

;******************************
; Таблица векторов прерываний
	jmp	RESET		; Reset Handler
	jmp	EXT_INT0	; IRQ0 Handler
	jmp	EXT_INT1	; IRQ1 Handler
	jmp	EXT_INT2	; IRQ2 Handler
	jmp	EXT_INT3	; IRQ3 Handler
	jmp	EXT_INT4	; IRQ4 Handler
	jmp	EXT_INT5	; IRQ5 Handler
	jmp	EXT_INT6	; IRQ6 Handler
	jmp	EXT_INT7	; IRQ7 Handler
	jmp	TIM2_COMP	; Timer2 Compare Handler
	jmp	TIM2_OVF	; Timer2 Overflow Handler
	jmp	TIM1_CAPT	; Timer1 Capture Handler
	jmp	TIM1_COMPA	; Timer1 CompareA Handler
	jmp	TIM1_COMPB	; Timer1 CompareB Handler
	jmp	TIM1_OVF	; Timer1 Overflow Handler
	jmp	TIM0_COMP	; Timer0 Compare Handler
	jmp	TIM0_OVF	; Timer0 Overflow Handler
	jmp	SPI_STC		; SPI Transfer Complete Handler
	jmp	USART0_RXC	; USART0 RX Complete Handler
	jmp	USART0_DRE	; USART0,UDR Empty Handler
	jmp	USART0_TXC	; USART0 TX Complete Handler
	jmp	ADCCCH		; ADC Conversion Complete Handler
	jmp	EE_RDY		; EEPROM Ready Handler
	jmp	ANA_COMP	; Analog Comparator Handler
	jmp	TIM1_COMPC	; Timer1 CompareC Handler
	jmp	TIM3_CAPT	; Timer3 Capture Handler
	jmp	TIM3_COMPA	; Timer3 CompareA Handler
	jmp	TIM3_COMPB	; Timer3 CompareB Handler
	jmp	TIM3_COMPC	; Timer3 CompareC Handler
	jmp	TIM3_OVF	; Timer3 Overflow Handler
	jmp	USART1_RXC	; USART1 RX Complete Handler
	jmp	USART1_DRE	; USART1,UDR Empty Handler
	jmp	USART1_TXC	; USART1 TX Complete Handler
	jmp	TWI		; Two-wire Serial Interface Handler
	jmp	SPM_RDY		; SPM Ready Handler

;
;******************************
;;;;; Первичная инициализация
RESET:
; Set Stack Pointer to top of RAM
	ldi	temp,high(RAMEND)
	out	SPH,temp
	ldi	temp,low(RAMEND)
	out	SPL,temp
; выкл. аналог, компаратор
	ldi	temp,1<<ACD
	out	ACSR,temp
; Enable interrupts
	sei

;******************************
;;;;; Основная программа
BEGIN:
	rjmp	BEGIN

;******************************
;;;;; Подпрограммы

;******************************
;;;;; Обработчики прерываний

; IRQ0 Handler
EXT_INT0:
	reti

; IRQ1 Handler
EXT_INT1:
	reti

; IRQ2 Handler
EXT_INT2:
	reti

; IRQ3 Handler
EXT_INT3:
	reti

; IRQ4 Handler
EXT_INT4:
	reti

; IRQ5 Handler
EXT_INT5:
	reti

; IRQ6 Handler
EXT_INT6:
	reti

; IRQ7 Handler
EXT_INT7:
	reti

; Timer2 Compare Handler
TIM2_COMP:
	reti

; Timer2 Overflow Handler
TIM2_OVF:
	reti

; Timer1 Capture Handler
TIM1_CAPT:
	reti

; Timer1 CompareA Handler
TIM1_COMPA:
	reti

; Timer1 CompareB Handler
TIM1_COMPB:
	reti

; Timer1 Overflow Handler
TIM1_OVF:
	reti

; Timer0 Compare Handler
TIM0_COMP:
	reti

; Timer0 Overflow Handler
TIM0_OVF:
	reti

; SPI Transfer Complete Handler
SPI_STC:
	reti

; USART0 RX Complete Handler
USART0_RXC:
	reti

; USART0,UDR Empty Handler
USART0_DRE:
	reti

; USART0 TX Complete Handler
USART0_TXC:
	reti

; ADC Conversion Complete Handler
ADCCCH:
	reti

; EEPROM Ready Handler
EE_RDY:
	reti

; Analog Comparator Handler
ANA_COMP:
	reti

; Timer1 CompareC Handler
TIM1_COMPC:
	reti

; Timer3 Capture Handler
TIM3_CAPT:
	reti

; Timer3 CompareA Handler
TIM3_COMPA:
	reti

; Timer3 CompareB Handler
TIM3_COMPB:
	reti

; Timer3 CompareC Handler
TIM3_COMPC:
	reti

; Timer3 Overflow Handler
TIM3_OVF:
	reti

; USART1 RX Complete Handler
USART1_RXC:
	reti

; USART1,UDR Empty Handler
USART1_DRE:
	reti

; USART1 TX Complete Handler
USART1_TXC:
	reti

; Two-wire Serial Interface Handler
TWI:
	reti

; SPM Ready Handler
SPM_RDY:
	reti

.exit
