Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. .def tmp = r16
  2.  
  3. .cseg
  4. rjmp reset
  5.  
  6. reset:
  7. ldi tmp, high(RAMEND)
  8. out SPH, tmp
  9. ldi tmp, low(RAMEND)
  10. out SPL, tmp
  11.  
  12. ldi tmp, (1 << PD4)
  13. out DDRD, tmp
  14.  
  15. ldi tmp, (1 << COM1B1) | (1 << COM1B0) | (1 << WGM11) ; COM1B0 je dodan na za inverting
  16. out TCCR1A, tmp
  17.  
  18. ldi tmp, (1 << WGM12) | (1 << CS10)
  19. out TCCR1B, tmp
  20.  
  21. ; foc1x = fclk / (2 * N * (1 + TOP)) TOP = OCR1A
  22. ; N = fclk / (foc1 * (1 + TOP))
  23. ; N = 7372800 / (20 * 256)
  24. ; N = 1440 -> N = 1024
  25.  
  26. ; foc1 = 7372800 / (1024 * (1 + 255))
  27. ; foc1 = 28.125 HZ
  28.  
  29. ; odrediti duty cicle od 50% u ocr1b registru
  30. ; DC = CMP / TOP
  31. ; CMP = DC * TOP
  32. ; CMP = 0.5 * 512
  33. ; CMP = 255
  34.  
  35. ldi tmp, high(5)
  36. out OCR1BH, tmp
  37. ldi tmp, low(5)
  38. out OCR1BL, tmp
  39.  
  40. main:
  41. rjmp main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement