kirill_76rus

lab_2_kovtunoff

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