Guest User

Untitled

a guest
Apr 16th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;---------------------------------------------------------
  2. ; Name: ausgabe_verschieben
  3. ; Purpose: LED's nach links shiften
  4. ; Input:    Port 4
  5. ; Return: Port 4
  6. ; Destroys: Nothing
  7. ;---------------------------------------------------------
  8. ausgabe_verschieben:
  9. ;save register
  10.  
  11.     push.w SR
  12.  
  13. ;verschiebe ausgabe
  14.  
  15.     clrc
  16.     rla.b LED
  17.     adc.b LED
  18.  
  19. ;return
  20.     pop.w SR
  21.     ret
  22.  
  23. ;---------------------------------------------------------
  24. ; Name: wait8MHz
  25. ; Purpose: warte x * 1msec
  26. ; Input: R6 = anzahl ms
  27. ; Return: nothing
  28. ; Destroys: nothing
  29. ;---------------------------------------------------------
  30. wait8MHz:
  31.  
  32. ;save register
  33.     push SR
  34.     push R8
  35.     push R6
  36.  
  37.  
  38. outer_loop:
  39.     mov.w #2666, R8
  40. inner_loop:
  41.     dec.w R8
  42.     jnz inner_loop
  43.     dec.w R6
  44.     jnz outer_loop
  45.  
  46.     pop R6
  47.     pop R8
  48.     pop SR
  49.  
  50.     ret
  51.  
  52. ;---------------------------------------------------------
  53. ; Module/Filename: automatikbetrieb.asm
  54. ; HW-System: MSP430f1611 / BOCAS
  55. ; IDE: CodeComposer Studio
  56. ; Purpose: LED-Lauflicht
  57. ; Author:
  58. ; Dates: 19.11.2011
  59. ;---------------------------------------------------------
  60.     .global main
  61.     .cdecls "msp430f1611.h"
  62.     .text
  63.  
  64. ;definitionen
  65. &P4OUT  .equ LED
  66. #0x10   .equ taster
  67. #0x02   .equ schalter
  68.  
  69. ;Variablen:
  70. ;R6 - Zeitvariable
  71. main:
  72.  
  73. ;init ports
  74.     mov.b #0x00,    &P1SEL      ;digital i/o for P1
  75.     bic.b #0xFF,    &P1DIR      ;input mode for all pins
  76.     mov.b #0x00,    &P4SEL      ;digital i/o for P4
  77.     bis.b #0xFF,    &P4DIR      ;output mode for all pins
  78.     mov.b #0x07,    &P4OUT      ;anfangswert an port 4 legen
  79.  
  80. loop:
  81.  
  82. PRESSED:
  83. ;teste ob taster gedrueckt wurde
  84.     bit.b taster, &P1IN         ;#0x10 and P1IN -> SR
  85.     jnz PRESSED
  86.  
  87. ;test ob schalter auf handbetrieb oder automatik steht
  88.     bit.b schalter, &P1IN
  89.     jz handbetrieb
  90.     jmp automatik
  91.  
  92. handbetrieb:
  93.  
  94. ;warte 30 ms zur entprellung
  95.     mov.w #30,R6
  96.     call #wait8MHz
  97.  
  98. ;teste ob taster NICHT gedrueckt wurde
  99.     bit.b taster, &P1IN             ;#0x10 and P1IN -> SR
  100.     jz loop
  101.  
  102. ;rufe unterprogramm auf
  103.     call #ausgabe_verschieben
  104.     jmp loop
  105.  
  106. automatik:
  107.  
  108. ;warte 500 ms
  109.     mov.w #500,R6
  110.     call #wait8MHz
  111.  
  112. ;ausgabe verschieben
  113.     call #ausgabe_verschieben
  114.     jmp loop
Add Comment
Please, Sign In to add comment