SHARE
TWEET

zadatak 4 L02

KgCro Oct 15th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //L02 zadatak 4
  2. //trcece svjetlo
  3.  
  4. .equ delayCnt = 15 // ovo racunamo sa onom formulom za X
  5.  
  6. .def tmp = r16
  7. .cseg
  8.     rjmp reset
  9.  
  10. reset:
  11.     ldi tmp,high(RAMEND)
  12.     out SPH, tmp
  13.     ldi tmp, low(RAMEND)
  14.     out SPL, tmp
  15.    
  16.     ldi tmp, 0xff // cijeli port je aktivan
  17.     out DDRA, tmp
  18.     out PORTA , tmp
  19.  
  20.  
  21.     main:
  22.         rcall runningled
  23.         rcall delay
  24.     rjmp main
  25.  
  26.     /*
  27.         fl = 1 / 0.4 <- frekvencija koja nam treba (u onoj formuli)
  28.  
  29.         X = (7372800+(1/0,4)) / ((1/0,4)*197122)) = 15
  30.    
  31.     */
  32.  
  33.  
  34.  
  35.     runningled:
  36.         push tmp //pusha na stack
  37.         in tmp, PORTA //ucita podatak s porta
  38.         rol tmp
  39.         out PORTA, tmp
  40.         pop tmp // vraca iz stacka
  41.     ret
  42.  
  43.     delay:
  44.         push r17
  45.         push r18
  46.         push r19
  47.  
  48.         clr r17
  49.         clr r18
  50.         ldi r19, delayCnt
  51.  
  52.         delay_loop:
  53.             dec r17 ; 0,255 , 254... , 0
  54.             brne delay_loop
  55.                 dec r18 ; 0,255,254,...,0
  56.                 brne delay_loop
  57.                     dec r19 ; n,n-1
  58.                     brne delay_loop
  59.         pop r19
  60.         pop r18
  61.         pop r17
  62.  
  63. ret
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top