Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. ; test.asm Port J Output
  2.  
  3. LIST P=18F97J60 ; directive to define processor
  4. #include <P18F97J60.INC> ; processor specific variable definition
  5. config XINST = OFF
  6. config FOSC = HS
  7. config WDT = OFF
  8.  
  9.  
  10. ORG 0x0000
  11. ResetV goto MAIN ; Skip over interrupt vectors
  12.  
  13. ORG 0x0008
  14. HPISR
  15. retfie
  16.  
  17. ORG 0x0018
  18. LPISR
  19. retfie
  20.  
  21. ORG 0x0100 ; Suggest starting address for codes
  22. MAIN
  23. movlw 0x00 ;initilise PortD (motor) to output
  24. movwf TRISD,0
  25.  
  26. movlw B'00000000' ;clear PortD
  27. movwf LATD,0
  28.  
  29. movlw 0x00 ;initialise PortJ (LED) to output
  30. movwf TRISJ,0
  31.  
  32. movlw B'00000001' ;initialise
  33. movwf LATJ,0
  34.  
  35. movlw 0xFF
  36. movwf TRISB,0
  37.  
  38. movlw 0x00
  39. movwf TRISC,0
  40.  
  41. movlw 0x00
  42. movwf TRIS
  43.  
  44. movlw 0x3d
  45. movwf PR2,0
  46.  
  47. movlw B'01111111'
  48. movwf T2CON
  49.  
  50. movlw 0x00
  51. movwf 0x05
  52.  
  53. movlw 0x00
  54. movwf 0x04
  55.  
  56.  
  57.  
  58. step1 movlw 0x00
  59. movwf PORTC,0
  60.  
  61. btfss PORTB,1,0
  62. goto john
  63.  
  64. movlw 0x01
  65. movwf PORTD,0
  66.  
  67. btfss PIR1,1,0
  68. goto step1
  69.  
  70. bcf PIR1,1,0
  71.  
  72. step2 btfss PORTB,1,0
  73. goto john
  74.  
  75. movlw 0x02
  76. movwf PORTD,0
  77.  
  78. btfss PIR1,1,0
  79. goto step2
  80.  
  81. bcf PIR1,1,0
  82.  
  83. step3 btfss PORTB,1,0
  84. goto john
  85.  
  86. movlw 0x04
  87. movwf PORTD,0
  88.  
  89. btfss PIR1,1,0
  90. goto step3
  91.  
  92. bcf PIR1,1,0
  93.  
  94.  
  95. step4 btfss PORTB,1,0
  96. goto john
  97.  
  98. movlw 0x08
  99. movwf PORTD,0
  100.  
  101. btfss PIR1,1,0
  102. goto step4
  103.  
  104. bcf PIR1,1,0
  105.  
  106.  
  107. incf 0x05,1,0
  108. movlw 0x64
  109. cpfsgt 0x05,0
  110. bra step1
  111.  
  112.  
  113. incf LATJ,1,0
  114. movlw 0x00
  115. movwf 0x05
  116.  
  117. movlw 0x00
  118. movwf 0x04
  119. bra step1
  120. ; Trap CPU here
  121.  
  122. john movlw 0xFF
  123. movwf PORTC,0
  124.  
  125. movlw 0x00
  126. movwf PORTD,0
  127. btfss PORTB,0,0
  128. goto step1
  129. goto john
  130.  
  131.  
  132. END ; No code beyond this line, absolutely.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement