Advertisement
Guest User

s tipkama

a guest
Dec 9th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.08 KB | None | 0 0
  1. ;
  2. ; Zadatak1.asm
  3. ;
  4. ; Created: 9.12.2018. 20:08:56
  5. ; Author : Maja Vrsaljko
  6. ;
  7.  
  8. .def tmp = r16
  9. .def counter = r17
  10. .def step = r18
  11.  
  12.  
  13. .cseg
  14.     rjmp reset
  15. /*
  16. .org $002
  17.     rjmp inc_int
  18. .org $004
  19.     rjmp dec_int
  20.     */
  21. reset:
  22.     ldi tmp, high(RAMEND)
  23.     out SPH, tmp
  24.     ldi tmp, low(RAMEND)
  25.     out SPL, tmp
  26.  
  27.     ldi tmp, (1 << PD5)//pin
  28.     out DDRD, tmp
  29.  
  30.     ldi tmp, (1 << 0) | (1 << 1)
  31.     out PORTB, tmp //tipkice
  32.  
  33.     ldi tmp, (1 << COM1A0) | (1 << COM1A1) | (1 << WGM10)
  34.     out TCCR1A, tmp
  35.  
  36.     ldi tmp, (1 << CS11) | (1 << WGM12)
  37.     out TCCR1B, tmp
  38.    
  39.     ldi tmp, high(200)
  40.     out OCR1AH, tmp
  41.     ldi tmp, low(200)
  42.     out OCR1AL, tmp
  43.  
  44.     ldi step, 0x05
  45.     /*
  46.     ldi tmp, (1 << ISC01) | (1 << ISC11)
  47.     out MCUCR, tmp
  48.     ldi tmp, (1 << INT0) | (1 << INT1)
  49.     out GICR, tmp
  50.     sei
  51.     */
  52. main:
  53.     sbis PINB, 0
  54.         rcall inc_int
  55.     sbis PINB, 1
  56.         rcall dec_int
  57. rjmp main
  58.  
  59. inc_int:
  60.     ldi tmp, 250
  61.     in counter, OCR1AL
  62.  
  63.     cpse counter, tmp
  64.         add counter, step
  65.  
  66.     out OCR1AL, counter
  67. //reti
  68. ret
  69.  
  70. dec_int:
  71.     ldi tmp, 0
  72.     in counter, OCR1AL
  73.  
  74.     cpse counter, tmp
  75.         sub counter, step
  76.  
  77.     out OCR1AL, counter
  78. //reti
  79. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement