Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .include "m16def.inc" ;
  2. .def Temp = r16  ;
  3. .def Temp1 = r17 ;
  4. .def Temp2 = r18
  5. .def Temp3 = r19
  6. .def Temp4 = r21
  7. .def ResCnt = r20 ;
  8. ldi Temp, 0xff ;
  9. out DDRD, Temp ;
  10. ldi Temp, 0x00 ;
  11. out DDRB, Temp ;
  12. ldi Temp, 0xff
  13. out PORTB, Temp ;
  14. ldi ResCnt, 13
  15. ldi Temp4, 8
  16. ldi Temp,HIGH(RamEnd)
  17. out SPH,Temp
  18. ldi Temp,Low(RamEnd)
  19. out SPL,Temp
  20. Proga:
  21.     rcall Button ;
  22.     ldi Temp, 0b11111110 ;
  23.     out PORTD, Temp ;
  24.     rcall Delay  ;
  25.     rcall Button ;
  26.     ldi Temp, 0b11111111
  27.     out PORTD, Temp ;
  28.     rcall Delay  ;
  29.     rcall Button ;
  30.  
  31.     ldi Temp, 0b11111101
  32.     out PORTD, Temp ;
  33.     rcall Delay ;
  34.     rcall Button ;
  35.  
  36.     ldi Temp, 0b11111111
  37.     out PORTD, Temp ;
  38.     rcall Delay ;
  39.     rcall Button ;
  40.  
  41.     ldi Temp, 0b11111011
  42.     out PORTD, Temp ;
  43.     rcall Delay ;
  44.     rcall Button ;
  45.     ldi Temp, 0b11111111
  46.     out PORTD, Temp ;
  47.     rcall Delay ;
  48.     rcall Button ;
  49.     ldi Temp, 0b11110111
  50.     out PORTD, Temp ;
  51.     rcall Delay ;
  52.     rcall Button ;
  53.     ldi Temp, 0b11111111
  54.     out PORTD, Temp ;
  55.     rcall Delay ;
  56.     rcall Button ;
  57.     rjmp Proga
  58.  
  59. Delay:    out PortD,Temp
  60.           ldi Temp1, 115
  61.           ldi Temp2, 46
  62.            mov Temp3, ResCnt
  63. Loop:     dec Temp1
  64.           brne Loop
  65.           dec Temp2
  66.           brne Loop
  67.           dec Temp3
  68.           brne Loop
  69.           ret  
  70. RButton:
  71.           ldi Temp1,0
  72.           ldi Temp2,0
  73. r_but:
  74.           dec Temp1
  75.           brne r_but
  76.           dec Temp2
  77.           brne r_but
  78.           add ResCnt, Temp4
  79.           cpi ResCnt, 65
  80.           brlo m2
  81.           ldi ResCnt, 65  
  82. m2:                                
  83.           ret
  84. LButton:
  85.           ldi Temp1,0
  86.           ldi Temp2,0
  87.  
  88. l_but:
  89.           dec Temp1
  90.           brne l_but
  91.           dec Temp2
  92.           brne l_but  
  93.           sub ResCnt, Temp4
  94.           cpi ResCnt, 13
  95.           brge  m1
  96.           ldi ResCnt, 13
  97. m1:
  98.           ret
  99. Button:
  100.           sbis PINB, PB2 ;
  101.           rcall LButton ;
  102.           sbis PINB, PB3 ;
  103.           rcall RButton ;
  104.           ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement