kirill_76rus

lab_2_romchik

Apr 7th, 2022
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. ;
  2. ; lab_2.asm
  3. ;
  4. ; Created: 07.04.2022 18:29:25
  5. ; Author : ferna
  6. ;
  7. .include "m168padef.inc" ;todo: switch to your MCU
  8.  
  9. ; Replace with your application code
  10. .CSEG
  11. .ORG $0000 ; (RESET)
  12. JMP init ;
  13. .ORG $001A ;switch to your address irq into datasheet
  14. jmp invert_state ;
  15.  
  16. .ORG INT_VECTORS_SIZE ; Конец таблицы прерываний
  17. jmp init
  18. start:
  19. nop
  20. nop
  21. jmp start
  22.  
  23.  
  24. init:
  25. ldi r16, low(ramend)
  26. ldi r17, high(ramend)
  27. out spl, r16
  28. out sph, r17
  29. sbi ddrb, 5;todo:switch to pb7
  30. rcall tim_init
  31. sei;enable global interrupts
  32. jmp start
  33.  
  34. invert_state:
  35. ;todo:switch all to pb7
  36. sbis pinb, 5;check for set state, if it's set - skip next cmd
  37. sbi portb, 5
  38. sbic pinb, 5
  39. cbi portb, 5
  40. reti
  41.  
  42. tim_init:
  43. ldi r16, (1<<CS12);prescale bits 0b100 = 256d
  44. sts TCCR1B, r16
  45. ldi r16, (1<<TOIE1) ;enable interrupts into timers
  46. sts TIMSK1, r16
  47. sei
  48. ret
  49.  
Advertisement
Add Comment
Please, Sign In to add comment