Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. ;**********************************************************************
  2. ; *
  3. ;**********************************************************************
  4. ; *
  5. ; Filnavn: jannichpetersen.asm *
  6. ; Dato: 09-11-2016 *
  7. ; *
  8. ; *
  9. ; Udvikler: JAPE *
  10. ; Firma: OTG *
  11. ; *
  12. ; *
  13. ;**********************************************************************
  14. ; *
  15. ; Nødvendige filer: P16F684.INC *
  16. ; *
  17. ;**********************************************************************
  18. ; *
  19. ; Bemærkninger: Ingen lige nu... *
  20. ; *
  21. ;**********************************************************************
  22.  
  23.  
  24. list p=16f684 ; list directive to define processor
  25. #include <P16F684.inc> ; processor specific variable definitions
  26.  
  27. __CONFIG _CP_OFF & _CPD_OFF & _BOD_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _MCLRE_ON & _FCMEN_OFF & _IESO_OFF
  28.  
  29.  
  30. ;********************************************************************
  31. ;BaseX EQU 0x23
  32. ;BaseY EQU 0x24
  33. ;Treshhold EQU 0x25
  34. Rounds EQU 0x26
  35. Round1 EQU 0x27 ;Bit 0 er 1 = Hurtig
  36.  
  37.  
  38. ;**********************************************************************
  39. ORG 0x000 ; processor reset vector
  40. goto Opsætning ; go to beginning of program
  41.  
  42.  
  43. INT_VECT CODE 0x0004
  44. GOTO ISR
  45.  
  46. MAIN_PROG CODE
  47.  
  48.  
  49. ;LIBRARYRYRYR
  50. #Include "delay.lib"
  51.  
  52. ;**********************************************************************
  53.  
  54. Opsætning
  55. ; Bank 0
  56. MOVLW b'00000111';
  57. MOVWF T2CON ; Start timer 2 (Bank 0, 12h)
  58.  
  59. MOVLW b'00000111';
  60. MOVWF CMCON0 ; Slukker for CM0,1,2 (Modsat) (Se Bank 0, 19h)
  61.  
  62. MOVLW b'00001100';
  63. MOVWF CCP1CON ; PWM Controller (Bank 0, 15h)
  64.  
  65. BSF STATUS,RP0 ; Skifter til BANK 1
  66. ; Bank 1
  67. BCF TRISC,5 ; Sætter bit 5 i Port C til output
  68.  
  69. MOVLW b'11111111';
  70. MOVWF PR2 ; Tænder timer 2 (Bank 1, 92h)
  71.  
  72. ; Sæt basisværdi for accelerometeret
  73. ; CALL delay1000 ; Efter 1 sekund
  74. ; CALL ADcheckX ;Find x-værdi for accelerometeret
  75. ; MOVWF BaseX
  76. ; CALL ADcheckY
  77. ; MOVWF BaseY ;Find x-værdi for accelerometeret
  78.  
  79. ; Opsætning af interrupt og runde-tælling
  80. MOVLW d'7'
  81. MOVWF Rounds
  82.  
  83. BSF STATUS,RP0 ; Skifter til BANK 1
  84. ; Opsætning af lysøje
  85. BSF TRISA,RA2 ;Sæt RA2 som input
  86. BCF ANSEL,ANS2 ;Sluk for analog
  87.  
  88. BCF TRISC,RC2 ;Sæt R2 som output BREMSELYS
  89. BCF TRISC,RC1 ;Sæt R2 som output BLINKLYS
  90. BCF TRISC,RC0 ;Sæt R2 som output BLINKLYS
  91.  
  92. BCF STATUS,RP0 ; Skifter til BANK 0
  93. MOVLW b'10010000'
  94. MOVWF INTCON ; Global interrupt enabled, RB Change interrupt enabled
  95. BCF Round1,0
  96.  
  97. goto main
  98.  
  99. ;**************************************************************************
  100. ISR
  101. BCF INTCON,GIE ;Disable all interrupts inside interrupt service routine
  102.  
  103. DECFSZ Rounds
  104. GOTO skip
  105. GOTO main
  106.  
  107. skip
  108.  
  109. BCF INTCON,INTF ;Clear interruptflag
  110. BSF INTCON,GIE ;Enable all interrupts
  111.  
  112.  
  113. GOTO start
  114.  
  115.  
  116. ;***********************************************************************
  117. main
  118. MOVLW d'0'
  119. MOVWF CCPR1L
  120.  
  121. CALL delay1000
  122.  
  123. MOVLW d'6'
  124. MOVWF Rounds
  125.  
  126. BCF INTCON,INTF ;Clear interruptflag
  127. BSF INTCON,GIE ;Enable all interrupts
  128.  
  129.  
  130. GOTO main
  131.  
  132.  
  133. start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement