Debian Codegraph @

ACME_Lib/cbm/cia.a

raw
1 ;ACME 0.96.4
2
3 !ifdef lib_cbm_cia_a !eof
4 lib_cbm_cia_a = 1
5
6 ; CBM's "complex interface adapter" chip, known as 6526.
7 ; A newer version of this chip was initially called 8521, but later the name was
8 ; changed back to 6526 again.
9
10 ; There are two of these in a C64/128 computer, and one in 1570/1571 drives.
11
12 ; pinout:
13 ; ____ ____
14 ; | V |
15 ; GND | 1 40 | cnt clock for shift register
16 ; / pa0 | 2 39 | sp data for shift register
17 ; | pa1 | 3 38 | a0 \
18 ; | pa2 | 4 37 | a1 |_ address
19 ; Port _| pa3 | 5 36 | a2 | bus
20 ; A | pa4 | 6 35 | a3 /
21 ; | pa5 | 7 34 | /reset
22 ; | pa6 | 8 33 | d0 \
23 ; \ pa7 | 9 32 | d1 |
24 ; / pb0 | 10 31 | d2 |
25 ; | pb1 | 11 30 | d3 |_ data
26 ; | pb2 | 12 29 | d4 | bus
27 ; Port _| pb3 | 13 28 | d5 |
28 ; B | pb4 | 14 27 | d6 |
29 ; | pb5 | 15 26 | d7 /
30 ; | pb6 | 16 25 | 0in clock
31 ; \ pb7 | 17 24 | /flag
32 ; /pc | 18 23 | /cs chip select
33 ; tod_clk | 19 22 | r/w
34 ; +5V | 20 21 | /irq
35 ; |_________|
36
37
38 ; register offsets:
39 ; two 8-bit ports:
40 cia_port_a = $0
41 cia_port_b = $1
42 cia_data_direction_a = $2 ; clear means input,
43 cia_data_direction_b = $3 ; set means output
44
45 ; two 16-bit timers, can be combined to form a single 32-bit timer:
46 cia_timer_a_low = $4
47 cia_timer_a_high = $5
48 cia_timer_b_low = $6
49 cia_timer_b_high = $7
50 ; reading returns current counter value,
51 ; writing sets start value.
52 ; in 32-bit mode, timer A is "low word" and timer B is "high word".
53
54 ; TOD (time of day) clock, clocked with 50 or 60 Hz:
55 ; (CAUTION, registers use binary coded decimal format)
56 cia_timeofday_10ths = $8 ; %....3210 0..9, counts 10ths of seconds
57 cia_timeofday_seconds = $9 ; %.6543210 0..59, as two BCD digits:
58 ; %.654.... 0..5 "tens"
59 ; %....3210 0..9 "ones"
60 cia_timeofday_minutes = $a ; %.6543210 0..59, as two BCD digits:
61 ; %.654.... 0..5 "tens"
62 ; %....3210 0..9 "ones"
63 cia_timeofday_hours = $b ; %7..43210 AM/PM and 1..12 as two BCD digits:
64 ; %7....... 0 means AM, 1 means PM
65 ; %...4.... 0..1 "tens"
66 ; %....3210 0..9 "ones"
67 ; when reading or writing time, start with hours and end with 10ths:
68 ; accessing hours uncouples registers from clock, accessing 10ths re-couples them.
69 ; if your read access does not start with the hours register,
70 ; you have a race condition!
71
72 ; shift register:
73 ; msb is sent/received first. send clock is half of timer A's underflow rate.
74 cia_serial_data = $c
75
76 ; control registers:
77 cia_interrupt_control = $d
78 ; %7....... read: 1 = interrupt requested (reading clears register)
79 ; write: 0 = disable interrupts indicated by set bits
80 ; 1 = enable interrupts indicated by set bits
81 ; %.65..... unused
82 ; %...4.... negative edge on /flag detected
83 ; %....3... shift register has finished sending or receiving
84 ; %.....2.. time of day alarm
85 ; %......1. timer B underflow
86 ; %.......0 timer A underflow
87
88 cia_control_a = $e
89 ; %7....... TOD clock: 0 means 60 Hz, 1 means 50 Hz
90 ; %.6...... shift register direction: 0 = input, 1 = output
91 ; %..5..... timer A clock: 0 = system clock, 1 = CNT
92 ; %...4.... 1 = force load timer start value
93 ; %....3... timer mode: 0 = continuous, 1 = one-shot (needs restart via bit 0)
94 ; %.....2.. 0 = pulse on PB6, 1 = invert PB6
95 ; %......1. 1 = timer underflow shows on PB6 (this forces PB6 to output)
96 ; %.......0 0 stops timer, 1 starts timer
97
98 cia_control_b = $f
99 ; %7....... TOD write mode: 0 = actual time, 1 = alarm time (it is not possible to _read_ the alarm time!)
100 ; %.65..... timer B clock:
101 ; %00 = system clock
102 ; %01 = CNT
103 ; %10 = underflow of timer A
104 ; %11 = combination of %01 and %10
105 ; %...4.... 1 = force load timer start value
106 ; %....3... timer mode: 0 = continuous, 1 = one-shot (needs restart via bit 0)
107 ; %.....2.. 0 = pulse on PB7, 1 = invert PB7
108 ; %......1. 1 = timer underflow shows on PB7 (this forces PB7 to output)
109 ; %.......0 0 stops timer, 1 starts timer