Advertisement
Guest User

Untitled

a guest
Nov 1st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .nolist
  2. .include "m16def.inc"
  3. .list
  4. .listmac
  5. .device ATmega16
  6.                                ; // komentarz /* */
  7. .cseg
  8. // PC == 0000 z reguły, ale gdyby miało być inaczej
  9. .org 0x0000;
  10. // Omijamy wektory przerwań
  11. jmp 0x0030
  12.  
  13. .org 0x0030
  14.  
  15. /* ldi r16, 10
  16. ldi r17, 20
  17. add r16, r17
  18. */
  19.  
  20. //opóźnianie o 104us
  21. //stos
  22.         ldi r16, low(RAMEND) // ldi r16, 0x5f
  23.         out SPL, r16
  24.         ldi r16, high(RAMEND) // ldi r16, 0x04
  25.         out SPH, r16
  26.  
  27. //kierunek portu B
  28.         ldi r16,0b00000001 //najmłodsza linia jako input, reszta jako output
  29.         out DDRB, r16
  30.  
  31. loop:
  32.         call wait_104
  33.                 call wait_104
  34.                         call wait_104
  35.                                 call wait_104
  36.                                         call wait_104
  37.  
  38. //bit startu 0
  39.        //ldi r16, 0b00000000
  40.        //out PORTB, r16 alternatywa
  41.         cbi PORTB, 0
  42.         call wait_104
  43. //wyślij 1
  44.         sbi PORTB, 0
  45.         call wait_104
  46. //wyślij 0
  47.     cbi PORTB, 0
  48.         call wait_104
  49. //0
  50.     cbi PORTB, 0
  51.         call wait_104
  52. //0
  53.     cbi PORTB, 0
  54.         call wait_104
  55. //1
  56.     sbi PORTB, 0
  57.         call wait_104
  58. //1
  59.     sbi PORTB, 0
  60.         call wait_104
  61. //0
  62.     cbi PORTB, 0
  63.         call wait_104
  64. //0
  65.     cbi PORTB, 0
  66.         call wait_104
  67. //bit stopu 1
  68.     sbi PORTB, 0
  69.         call wait_104
  70.         jmp loop
  71.  
  72.         .org 0x100
  73.         wait_104:
  74.     ldi  r18, 2
  75.     ldi  r19, 17
  76. L1: dec  r19
  77.     brne L1
  78.     dec  r18
  79.     brne L1
  80.         ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement