-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestBlockingSIOOutputNoFlowControl.asm
More file actions
101 lines (90 loc) · 1.95 KB
/
testBlockingSIOOutputNoFlowControl.asm
File metadata and controls
101 lines (90 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
; WIRING
; CTC ZC/TO0 wired to SIO ~RxTxC channel B
#include "constants.asm"
.org 8000h
; RESET CTC0
ld a, 03h
out (CTC0)
; Generate 9600 Hz from 4 MHz clock. 4M/(16*26)~=9615 Hz on CTC ZC/TO0
; 7=0 disable interrupts, 6=0 TIMER mode, 5=0 16 PRESCALER, 4=1 POS EDGE
; 3=0 AUTO Start, 2=1 TIME Constant follows, 1=0 Continue, 0 = 1
; 1001 0101 = B5
ld a, 015h
out (CTC0)
; Following time constant: set counter to 26
ld a, 26
out (CTC0)
;
; Setup SIO Channel B
;
; Channel reset WR0
; 0001 1000
ld a, 18h
out (SIO_B_CONTROL)
; WR4 should be initialized first according to documentation
; Reset ext/status interrupts, select WR4
ld a, 14h
out (SIO_B_CONTROL)
; x1 clock External sync, No parity, 1 stop bit,
;D0 0 No parity
;D1 N/A Parity ~Odd/Even
;D3, D2 01 One stop bit
;D5, D4 00 00 according to asyncronous section
;D7, D6 00 X1 clock
; 0000 0100
ld a, 04h
out (SIO_B_CONTROL)
; WR3: 11 8 bits, 0 No Auto Enable, 0000, 0 No enalbe Rx
; (auto enable requires ~CTS to be set
; 1100 0000
ld a, 03h
out (SIO_B_CONTROL)
ld a, 0C0h
out (SIO_B_CONTROL)
; WR5: 0 No DTR active, 11 8 bits, 0 no break, 1 Tx Enable, 0, 0 RTS, 0
; 0110 1000
ld a, 05h
out (SIO_B_CONTROL)
ld a, 068h
out (SIO_B_CONTROL)
; WR1, Reset External/Status Interrupts
; D1=0 Transmit interrupt disable, D0=0 External Interrupts disable
ld a, 11h
out (SIO_B_CONTROL)
ld a, 00h
out (SIO_B_CONTROL)
ld de, starting_string
call BLOCKING_SEND
; Transmit string to SIO
ld hl, output_string
loop:
; Check D2 of RR0 for transmit buffer empty
ld a, 00h
out (SIO_B_CONTROL)
in (SIO_B_CONTROL)
and 04h
jr z, loop
; Write the next byte to the SIO
ld a, '.'
call PUT_CHAR
ld a, (hl)
or a
jr z, end
inc hl
out (SIO_B_DATA)
jr loop
end:
ret
counter0Int:
ei
reti
sioInt:
ei
reti
tick_string: .string "tick"
.int8 0
starting_string: .string "Starting output"
.int8 0
output_string: .string "Hello World!"
.int8 0
status_rr0: .int8 0