Advertisement
kirill_76rus

lab_2_kovtunoff

Apr 13th, 2022
1,742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. rcall tim_init
  37. rcall exti_init
  38. sei;enable global interrupts
  39. jmp start
  40.  
  41. invert_state:
  42. ;todo:switch all to pb7
  43. sbis pinb, 5;check for set state, if it's set - skip next cmd
  44. sbi portb, 5
  45. sbic pinb, 5
  46. cbi portb, 5
  47. reti
  48.  
  49. tim_init:
  50. ldi r16, (1<<CS12);prescale bits 0b100 = 256d
  51. sts TCCR1B, r16
  52. ldi r16, (1<<TOIE1) ;enable interrupts into timers
  53. sts TIMSK1, r16
  54. ret
  55.  
  56. EXTI_Init:
  57. ldi r16, ISC01
  58. sts EICRA, r16
  59. LDI R16, INT0
  60. sts EIMSK, R16
  61. ret
  62.  
  63. clr_counter:
  64. ldi r16, 0x00
  65. STS TCNT1L, R16
  66. STS TCNT1H, R16
  67. reti
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement