Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. #include <P16F628A.INC>
  2. __CONFIG _WDT_OFF
  3. cont0 EQU 0x20
  4. cont1 EQU 0x21
  5. cont2 EQU 0x22
  6. curva EQU 0x23
  7. posicao_inicial EQU 0x24
  8. org 0x00
  9. goto setup
  10.  
  11. org 0x04
  12. retfie
  13.  
  14. setup
  15. banksel TRISB
  16. movlw b'11100000'
  17. movwf TRISB
  18. banksel PORTB
  19. movfw PORTB
  20. clrf PORTB
  21. banksel posicao_inicial
  22. movwf posicao_inicial
  23. movlw 0x07
  24. movwf curva
  25. goto main
  26.  
  27. main
  28. call reto
  29. btfsc PORTB, 5; bit 5 informa se está em curva
  30. goto trat_curva1 ;se estiver, chama a rotina
  31. goto main
  32.  
  33. reto
  34. banksel PORTB
  35. ;Configurando o MOTOR1
  36. bsf PORTB,RB0
  37. bcf PORTB,RB1
  38. ;Configurando o MOTOR2
  39. bsf PORTB,RB2
  40. bcf PORTB,RB3
  41. call atraso
  42. return
  43.  
  44. trat_curva1
  45. btfss curva, 2
  46. goto trat_curva2; vai pro btfss curva, 1
  47. btfsc posicao_inicial, 7
  48. call curva_direita
  49. btfss posicao_inicial, 7
  50. call curva_esquerda
  51. bcf curva, 2
  52. call atraso
  53. goto main
  54.  
  55. trat_curva2
  56. btfss curva, 1
  57. goto trat_curva3;vai pro btfss curva, 0
  58. btfsc posicao_inicial, 6
  59. call curva_direita
  60. btfss posicao_inicial, 6
  61. call curva_esquerda
  62. bcf curva, 1
  63. call atraso
  64. goto main
  65.  
  66. trat_curva3
  67. ;btfsc curva, 0
  68. ;goto setup2
  69. goto fim
  70.  
  71. setup2
  72. banksel posicao_inicial
  73. comf posicao_inicial, 1
  74. movlw 0x06
  75. movwf curva
  76. call cento_e_oitenta
  77. call atraso
  78. goto main
  79.  
  80. ;<curvas>
  81. curva_esquerda
  82. banksel PORTB
  83. bcf PORTB, 0
  84. bcf PORTB, 1
  85. return
  86.  
  87. curva_direita
  88. banksel PORTB
  89. bcf PORTB, 2
  90. bcf PORTB, 3
  91. return
  92.  
  93. cento_e_oitenta
  94. banksel PORTB
  95. bsf PORTB, 0
  96. bcf PORTB, 1
  97. bcf PORTB, 2
  98. bsf PORTB, 3
  99. return
  100. ;</curvas>
  101.  
  102.  
  103. ;<atraso>
  104. atraso
  105. banksel cont0
  106. movlw 0xff
  107. movwf cont0
  108. goto atraso_00
  109.  
  110. atraso_00
  111. movlw 0x80
  112. movwf cont1
  113. decfsz cont0
  114. goto atraso_01
  115. return
  116.  
  117. atraso_01
  118. movlw 0x40
  119. movwf cont2
  120. decfsz cont1
  121. goto atraso_02
  122. goto atraso_00
  123.  
  124. atraso_02
  125. decfsz cont2
  126. nop
  127. goto atraso_01
  128. ;</atraso>
  129.  
  130. fim
  131. banksel PORTB
  132. clrf PORTB
  133. goto fim
  134. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement