'===============================================================================
Interrupt_handling: '34 такта (счёт); 40 тактов (счёт + реакция на сравнение)
'-------------------------------------------------------------------------------
'If Val_word = 0 Then
'Stop Timer1
'Led = On_led
'Else
'Decr Val_word
'End If
!push R16
!in R16 , sreg
!push R16
!push R30
!push R31
!lds R30 , {Val_word}
!lds R31 , {Val_word + 1}
'If Val_word = 0 Then
!clr R16
!cpi R30 , 0
!cpc R31 , R16
!breq Reaction_compare_variables
!rjmp Decrement_variable
Reaction_compare_variables:
'Stop Timer1
!lds R16 , tccr1b
!andi R16 , &B_1111_1000
!sts tccr1b , R16
'Set Led
Led = On_led
!rjmp Exit_isr_compare1a
'Else
Decrement_variable:
'Decr Val_word
!sbiw R30 , 1 ' Вычесть константу из слова
Exit_interrupt_handling:
!sts {Val_word} , R30
!sts {Val_word + 1} , R31
'End If
!pop R31
!pop R30
!pop R16
!out sreg , R16
!pop R16
!reti
'-------------------------------------------------------------------------------
Return
'===============================================================================
'===============================================================================
Interrupt_handling: '41 такт (счёт); 49 тактов (счёт + реакция на сравнение)
'-------------------------------------------------------------------------------
'Incr Переменная_word
'If Переменная_word = Count Then
'Stop Timer1
'Переменная_word = 0
'Set Led
'End If
!push R26
!in R26 , sreg
!push R26
!push R27
!push R30
!push R31
'Incr Val_word
!lds R30 , {Val_word}
!lds R31 , {Val_word + 1}
!adiw R30 , 1 'Сложить константу и слово
!lds R26 , {Count_word}
!lds R27 , {Count_word + 1}
'If Val_word = Count Then
!cp R30 , R26
!cpc R31 , R27
!breq Reaction_compare_variables
!rjmp Exit_isr_compare1a
Reaction_compare_variables:
'Stop Timer1
!lds R30 , tccr1b
!andi R30 , &B_1111_1000
!sts tccr1b , R30
'Val_word = 0
!clr R30
!clr R31
'Set Led
Led = On_led
'End If
Exit_interrupt_handling:
!sts {Val_word} , R30
!sts {Val_word + 1} , R31
!pop R31
!pop R30
!pop R27
!pop R26
!out sreg , R26
!pop R26
!reti
'-------------------------------------------------------------------------------
Return
'===============================================================================