Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;
- ; lab_2.asm
- ;
- ; Created: 07.04.2022 18:29:25
- ; Author : ferna
- ;
- ;PINOUT:
- ;PD2 - INT0
- ;LED - PB5
- .include "m168padef.inc" ;todo: switch to your MCU
- ; Replace with your application code
- .CSEG
- .ORG $0000 ; (RESET)
- JMP init ;
- .ORG $0002
- jmp clr_counter
- .ORG $001A ;switch to your address irq into datasheet
- jmp invert_state ;
- .ORG INT_VECTORS_SIZE ; Конец таблицы прерываний
- jmp init
- start:
- nop
- nop
- jmp start
- init:
- ldi r16, low(ramend)
- ldi r17, high(ramend)
- out spl, r16
- out sph, r17
- sbi ddrb, 5;todo:switch to pb7
- rcall tim_init
- rcall exti_init
- sei;enable global interrupts
- jmp start
- invert_state:
- ;todo:switch all to pb7
- sbis pinb, 5;check for set state, if it's set - skip next cmd
- sbi portb, 5
- sbic pinb, 5
- cbi portb, 5
- reti
- tim_init:
- ldi r16, (1<<CS12);prescale bits 0b100 = 256d
- sts TCCR1B, r16
- ldi r16, (1<<TOIE1) ;enable interrupts into timers
- sts TIMSK1, r16
- ret
- EXTI_Init:
- ldi r16, ISC01
- sts EICRA, r16
- LDI R16, INT0
- sts EIMSK, R16
- ret
- clr_counter:
- ldi r16, 0x00
- STS TCNT1L, R16
- STS TCNT1H, R16
- reti
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement