Advertisement
Guest User

Untitled

a guest
Jan 10th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .set DDRB_o, 0x4
  2. .equ PORTB_o, 0x5
  3. PORTD_o = 0x0b
  4. DDRD_o = 0x0a
  5. PIND_o = 0x09
  6. PINB_o = 0x23
  7.    
  8. TCCR2A_o = 0xb0
  9. TCCR2B_o = 0xb1
  10. PORTD_o = 0x0b
  11. OCR2A_o = 0xb3
  12.    
  13. /*counter 2*/  
  14. OCR0A_o = 0x27
  15. TCCR0B_o  = 0x25
  16. TCCR0A_o = 0x24
  17.  
  18. /*Counter 1*/
  19. OCR1AL_o = 0x88
  20. OCR1AH_o = 0x8b
  21. TCCR1A_o = 0x80
  22. TCCR1B_o = 0x81
  23. TCCR1C_o = 0x82
  24. TCNT1L_o = 0x84
  25. TCNT1H_o = 0x85
  26. TIFR1_o = 0x16
  27. TIMSK1_o = 0x6f
  28.    
  29. /*Rx*/
  30. UDR0 = 0xc6
  31. UBRR0H = 0xc5
  32. UBRR0L = 0xc4
  33. UCSR0C = 0xc2
  34. UCSR0B = 0xc1
  35. UCSR0A = 0xc0
  36.    
  37. .global main
  38. .section .text
  39.  
  40. ledon:
  41.     ldi r16, 0x20
  42.     out PORTB_o, r16
  43.     ret
  44.  
  45. ledoff:
  46.     ldi r16, 0x00
  47.     out PORTB_o, r16
  48.     ret
  49.    
  50. main:
  51.     rcall   ledoff
  52.     //Se utiliza el Pin 7 como input
  53.     ldi     r17, 0b10000000
  54.     out     DDRD_o, r17
  55.    
  56.     //Para usar led
  57.     ldi     r17, 0x20
  58.     out     DDRB_o, r17
  59.     ldi     r17, 0
  60.     out     PORTB_o, r17
  61.    
  62.     //Iniciar timer y cosas
  63.     ldi     r17, 0b11000000
  64.     sts     TCCR0A_o, r17
  65.     ldi     r17, 0b00001101
  66.     sts     TCCR0B_o, r17
  67.     ldi     r17, 0b10000000
  68.     sts     TCCR1C_o, r17
  69.     //Comparador
  70.     ldi     r17, 0b10001001
  71.     sts     OCR1AL_o, r17 //Comparador  
  72.     ldi     r17, 0b00111101
  73.     sts     OCR1AH_o, r17
  74.    
  75.     //Interrupciones
  76.     //Contador maquina de estados
  77.     ldi     r18, 0b00000010
  78.     sts     TIMSK1_o, r18
  79.     sei
  80.    
  81. looop:
  82.     rcall   ledoff
  83.     rjmp    looop
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94. __vector_12:
  95. /*
  96.     cpi r18, 1
  97.     breq estatRatlla
  98.     cpi r18, 2
  99.     ---
  100. estatRatlla:
  101.     ratlla
  102. */
  103.     //rcall ledon
  104. reti   
  105.  
  106.    
  107. inici:
  108.     ldi     r18, 0 //Primer Estado
  109.     in      r20, PIND_o
  110.     sbrs    r20, 7 
  111.     rjmp    inici
  112.     rcall   punt
  113.  
  114. punt:
  115.     /*activar timer int. t(int)= punt + offset
  116.     comparar A  y reset timer
  117.     */
  118.     ldi r18, 1
  119.     sei
  120. loopPunt:
  121.     ldi     r20, PIND_o
  122.     sbrs    r20, 7
  123.     rjmp    silenci
  124.     rjmp    loopPunt
  125.    
  126.    
  127. silenci:
  128.     ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement