Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 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. .cseg
  13.     rjmp reset
  14.  
  15.  
  16. reset:
  17.     ldi tmp, high(RAMEND)
  18.     out SPH, tmp
  19.     ldi tmp, low(RAMEND)
  20.     out SPL, tmp
  21.  
  22.     ldi tmp, (1 << PD5)//pinovi
  23.     out DDRD, tmp
  24.  
  25.     ldi tmp, (1 << 0) | ( 1 << 1) //tipkice
  26.     out PORTB, tmp
  27.  
  28.     ldi tmp, 0x00
  29.     out DDRB, tmp
  30.  
  31.     //fiksini 8-bitni fast pwm /8 pres
  32.     ldi tmp, (1 << COM1A0) | (1 << COM1A1) | (1 << WGM10)
  33.     out TCCR1A, tmp
  34.  
  35.     ldi tmp, (1 << CS11) | (1 << WGM12)
  36.     out TCCR1B, tmp
  37.    
  38.     ldi tmp, high(200)
  39.     out OCR1AH, tmp
  40.     ldi tmp, low(200)
  41.     out OCR1AL, tmp
  42.  
  43.     ldi step, 0x05
  44.  
  45. main:
  46.     sbis PINB, 0
  47.         rcall inc_int
  48.     sbis PINB, 1
  49.         rcall dec_int
  50. rjmp main
  51.  
  52. inc_int:
  53.     ldi tmp, 0xfa //250
  54.     in counter, OCR1AL
  55.     cpse counter, tmp
  56.         add counter, step
  57.  
  58.     out OCR1AL, step
  59. ret
  60.  
  61. dec_int:
  62.     ldi tmp, 0x00
  63.     in counter, OCR1AL
  64.     cpse counter, tmp
  65.         sub counter, step
  66.  
  67.     out OCR1AL, step
  68. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement