Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.95 KB | None | 0 0
  1. org 100h
  2. cpu 8086
  3.  
  4. jmp start
  5.  
  6. ; Variablen
  7. status db 00000000b ; Statusbyte
  8. ; xxxx x
  9. ; |||| |
  10. ; |||| +--------> Vereinzeler (1, auf) / (0, zu) bzw.
  11. ; |||| Verzoegerung aktiv
  12. ; |||+------------> Merker für Lichttaster ?
  13. ; ++++------------> Anzahl Teile binaer (8-0)
  14.  
  15. tcounts db 0 ; Impulszaehler fuer Servo, Vorwaertszaehler
  16. tcountv dw 100 * twait ; Impulszaehler fuer Verzoegerung * 10ms
  17. ; Rueckwaertszaehler
  18. frei db 'frei ', 0 ; Texte
  19. belegt db 'belegt ', 0
  20. clrscrn db ' ', 0
  21.  
  22. ; Konstanten
  23. servo_timer equ 0 ; Zeitkonstante fuer Servo
  24. vereinzeler_timer equ 0 ; Zeitkonstante für Vereinzeler
  25. VE_aktiv equ 1 << 0 ; Vereinzeler bzw. Verzoegerung aktiv
  26. intab0 equ 20h ; Adresse Interrupttabelle PIT, Kanal 1
  27. intab1 equ intab0 + 1 * 4 ; Adresse Interrupttabelle PIT, Kanal 2
  28. intab7 equ intab0 + 7 * 4 ; Adresse Interrupttabelle Lichttaster
  29. eoi equ 20h ; End Of Interrupt (EOI)
  30. clrscr equ 0 ; Clear Screen
  31. getkey equ 1 ; Funktion auf Tastatureingabe warten
  32. ascii equ 2 ; Funktion ASCII-Zeichenausgabe
  33. hexbyte equ 4 ; HEX-Byte Ausgabe
  34. conin equ 5 ; Console IN
  35. conout equ 6 ; Console OUT
  36. pitc equ 0a6h ; Steuerkanal PIT
  37. pit1 equ 0a2h ; Counter 1 PIT
  38. pit2 equ 0a4h ; Counter 2 PIT
  39. ppi_ctl equ 0b6h ; Steuerkanal PPI (Parallelinterface)
  40. ppi_a equ 0b0h ; Kanal A PPI
  41. ppi_pa0 equ 1 ; LED 0
  42. ppi_pa1 equ 2 ; LED 1
  43. ppi_pa2 equ 4 ; LED 2
  44. ppi_pa3 equ 8 ; Lautsprecher
  45. ppi_pa6 equ 1 << 6 ; Servomotor
  46. ppi_b equ 0b2h ; Kanal B PPI
  47. ppi_c equ 0b4h ; Kanal C PPI
  48. ocw_2_3 equ 0c0h ; PIC (Interruptcontroller), OCW2,3
  49. ocw_1 equ 0c2h ; PIC (Interruptcontroller), OCW1
  50. icw_1 equ 0c0h ; PIC (Interruptcontroller), ICW1
  51. icw_2_4 equ 0c2h ; PIC (Interruptcontroller), ICW2,4
  52. leds equ 0 ; LED Port
  53. schalter equ 0 ; Schalterport
  54. keybd equ 80h ; SBC-86 Tastatur
  55. gokey equ 11h ; Taste "GO"
  56. outkey equ 15h ; Taste "OUT"
  57. sseg7 equ 9eh ; Segmentanzeige 7
  58. tcpwm equ 184 ; 1843200 Hz / 184 = ca. 10000 Hz = 0.1 ms
  59. ; Taktzyklus
  60. ; Zeitkonstante fuer PWM-Interrupt
  61. tpwm equ 200 ; Periodendauer des PWM-Signals * 0.1 ms
  62. tlinks equ 10 ; Impulsdauer fuer "ZU" * 0.1 ms
  63. trechts equ 20 ; Impulsdauer fuer "AUF" * 0.1 ms
  64. tcwait equ 18432 ; 1843200 Hz / 18432 = 100 Hz => 10 ms
  65. ; Zeitkonstante fuer Wartezeitinterrupt
  66. twait equ 1 ; Wartezeit fuer offenen Vereinzeler (s)
  67. shcnt equ 4 ; Shiftcount Anzahl Teile
  68. pieces equ 8 ; Anzahl Teile initial
  69.  
  70. start:
  71.  
  72. ; Initialisierung
  73.  
  74. call init ; Controller und Interruptsystem scharfmachen
  75.  
  76. mov ah, clrscr ; Anzeige aus
  77. int conout
  78.  
  79. mov byte [status], pieces << shcnt ; Init. Statusbyte und alle LEDs
  80. mov al, 0
  81. out ppi_a, al
  82. out leds, al
  83.  
  84. ; Hintergrundprogramm (ist immer aktiv, wenn im Service nichts zu tun ist)
  85. ; Hier sollten Ausgaben auf das Display getätigt werden, Zählung der Teile, etc.
  86.  
  87. again:
  88.  
  89. ; Ihr Programmcode...
  90.  
  91. mov ah, 2
  92. mov bx, clrscrn
  93. mov dl, 7
  94. int 6
  95. mov al, 0
  96. out schalter, al
  97.  
  98. mov al, [status]
  99. cmp al, 0
  100. je voll
  101.  
  102. struff:
  103. mov ah, 4h
  104. mov bx, [status]
  105. mov dl, 1h
  106. int 6
  107. mov ah, 2
  108. mov bx, frei
  109. mov dl, 7
  110. int 6
  111. mov al, [status]
  112. cmp al, 0
  113. je voll
  114. jmp struff
  115.  
  116. voll:
  117. mov ah, 2
  118. mov bx, clrscrn
  119. mov dl, 7
  120. int 6
  121.  
  122. mov ah, 2
  123. mov bx, belegt
  124. mov dl, 7
  125. int 6
  126.  
  127. jmp again
  128.  
  129. ; Initialisierung Controller und Interruptsystem
  130.  
  131. init:
  132. cli ; Interrupts aus
  133.  
  134. ; PIT-Init.
  135.  
  136. mov al, 01110110b ; Kanal 1, Mode 3, 16-Bit ZK
  137. out pitc, al ; Steuerkanal
  138. mov al, tcpwm & 0ffh ; Low-Teil Zeitkonstante
  139. out pit1, al
  140. mov al, tcpwm >> 8 ; High-Teil Zeitkonstante
  141. out pit1, al
  142.  
  143. mov al, 10110110b ; Kanal 2, Mode 3, 16-Bit ZK
  144. out pitc, al ; Steuerkanal
  145. mov al, tcwait & 0ffh ; Low-Teil Zeitkonstante
  146. out pit2, al
  147. mov al, tcwait >> 8 ; High-Teil Zeitkonstante
  148. out pit2, al
  149.  
  150.  
  151. ; PPI-Init.
  152. mov al, 10001011b ; PPI A/B/C Mode 0, A Output, sonst Input
  153. out ppi_ctl, al
  154. jmp short $+2 ; I/O-Delay
  155. mov al, 0 ; LED's aus (high aktiv)
  156. out ppi_a, al
  157.  
  158. ; PIC-Init.
  159. mov al, 00010011b ; ICW1, ICW4 benoetigt, Bit 2 egal,
  160. ; Flankentriggerung
  161. out icw_1, al
  162. jmp short $+2 ; I/O-Delay
  163. mov al, 00001000b ; ICW2, auf INT 8 gemapped
  164. out icw_2_4, al
  165. jmp short $+2 ; I/O-Delay
  166. mov al, 00010001b ; ICW4, MCS-86, EOI, non-buffered,
  167. ; fully nested
  168. out icw_2_4, al
  169. jmp short $+2 ; I/O-Delay
  170. mov al, 01111100b ; Kanal 0, 1 + 7 am PIC demaskieren
  171. ; PIT K1, K2 und Lichttaster
  172. out ocw_1, al
  173.  
  174. ; Interrupttabelle init.
  175. mov word [intab7], isr_lt ; Interrupttabelle (Lichttaster)
  176. ; initialisieren (Offset)
  177. mov [intab7 + 2], cs ; (Segmentadresse)
  178.  
  179. mov word [intab0], isr_servotimer ; Interrupttabelle (Timer K1)
  180. ; initialisieren (Offset)
  181. mov [intab0 + 2], cs ; (Segmentadresse)
  182.  
  183. mov word [intab1], isr_opentimer ; Interrupttabelle (Timer K2)
  184. ; initialisieren (Offset)
  185. mov [intab1 + 2], cs ; (Segmentadresse)
  186.  
  187. sti ; ab jetzt Interrupts
  188. ret
  189.  
  190. ;------------------------ Serviceroutinen ---------------------------------------------------------------------!!!
  191.  
  192. isr_opentimer: ; Timer fuer Vereinzeler (Zeit fuer Oeffnung)
  193. push ax
  194. ; Ihr Programmcode
  195.  
  196.  
  197. ; ---------------------------------------------------------------------------
  198. isr_opentimer_out: ; Ausgang aus dem Service
  199. mov al, eoi ; EOI an PIC
  200. out ocw_2_3, al
  201. pop ax
  202. iret
  203.  
  204. isr_lt: ; Lichttaster
  205. push ax
  206. ; Ihr Programmcode
  207. mov al, byte [status] ; Einlesung Statusbyte
  208. times 4 shr al,1 ;2^7 bis 2^4 nibble nach rechts schieben zu 2^3 bis 2^0
  209. dec al
  210.  
  211. cmp al, 0
  212. jge noch_nicht_null
  213. ; Blockade des Schalters nach Drücken
  214.  
  215.  
  216. ; wenn status = 0
  217. mov al, 00001000b
  218. times 4 shl al,1 ;2^3 bis 2^0 nibble nach links schieben zu 2^7 bis 2^4
  219. out leds, al ; resetting der leds
  220. jmp isr_lt_out
  221.  
  222. noch_nicht_null: ; Merker ist nicht gesetzt
  223. times 4 shl al,1 ;2^3 bis 2^0 nibble nach links schieben zu 2^7 bis 2^4
  224. mov ah, byte [status] ; Wieder-Setzung des Merkers
  225. and ah, 0x0F
  226. or al, ah
  227. or al, 1
  228. out leds, al ; Ausgabe des Merkers auf den LEDs
  229.  
  230.  
  231.  
  232. ; Verarbeitung der Request
  233. isr_lt_out: ; Ausgang aus dem Service
  234. mov [status], al
  235. mov al, eoi ; EOI an PIC
  236. out ocw_2_3, al
  237. pop ax
  238. iret
  239.  
  240. ; -------------------------------------------------------------------------------------------------------------!!!
  241. isr_servotimer: ; Timer fuer Servo (Vereinzeler)
  242. push ax
  243. ; Ihr Programmcode
  244. ; Registrierung von Lichttaster signal (wenn dieser zählt)
  245. ; Periodendauer des Zeitgeberkanals 100us (-> 0.1ms) ??? was soll das sein?
  246. ; Frequenz mitgeben durch pcie irgendwas
  247.  
  248.  
  249. ; Schließung des Vereinzelers
  250. ;linksdrehung:
  251. ; 1ms Signal
  252. ; Signalpause 19ms
  253. ; Aufruf von rechtsdrehung
  254.  
  255. ;rechtsdrehung:
  256. ; 2ms signal
  257. ; Signalpause 18ms
  258. ; aufruf von linksdrehung
  259.  
  260.  
  261. isr_servotimer_out: ; Ausgang aus dem Service
  262. mov al, eoi ; EOI an PIC
  263. out ocw_2_3, al
  264. pop ax
  265. iret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement