Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 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 curva_esquerda
  77. call atraso
  78. call atraso
  79. goto main
  80.  
  81. ;<curvas>
  82. curva_esquerda
  83. banksel PORTB
  84. bcf PORTB, 0
  85. bcf PORTB, 1
  86. return
  87.  
  88. curva_direita
  89. banksel PORTB
  90. bcf PORTB, 2
  91. bcf PORTB, 3
  92. return
  93. ;</curvas>
  94.  
  95.  
  96. ;<atraso>
  97. atraso
  98. banksel cont0
  99. movlw 0xff
  100. movwf cont0
  101. goto atraso_00
  102.  
  103. atraso_00
  104. movlw 0x80
  105. movwf cont1
  106. decfsz cont0
  107. goto atraso_01
  108. return
  109.  
  110. atraso_01
  111. movlw 0x40
  112. movwf cont2
  113. decfsz cont1
  114. goto atraso_02
  115. goto atraso_00
  116.  
  117. atraso_02
  118. decfsz cont2
  119. nop
  120. goto atraso_01
  121. ;</atraso>
  122.  
  123. fim
  124. banksel PORTB
  125. clrf PORTB
  126. goto fim
  127. end
  128.  
  129. https://ibb.co/R3ndCpr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement