cleanup
This commit is contained in:
parent
7214f1fe6f
commit
a63bd562d1
@ -1,4 +1,4 @@
|
|||||||
../rom.bin: main.asm6502 system/system.asm6502 system/io_W65C22.asm6502 utility.asm6502 /usr/share/cc65/asminc/longbranch.mac system/lcd.asm6502 utility.asm6502 system/keypad.asm6502 programs/printer.asm6502 programs/dht.asm6502
|
.build/test.o: test.s65 system/system.h65 system/io_W65C22.h65 utility.h65 /usr/share/cc65/asminc/longbranch.mac
|
||||||
|
|
||||||
main.asm6502 system/system.asm6502 system/io_W65C22.asm6502 utility.asm6502 /usr/share/cc65/asminc/longbranch.mac system/lcd.asm6502 utility.asm6502 system/keypad.asm6502 programs/printer.asm6502 programs/dht.asm6502:
|
test.s65 system/system.h65 system/io_W65C22.h65 utility.h65 /usr/share/cc65/asminc/longbranch.mac:
|
||||||
|
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
**.bin
|
**.bin
|
||||||
**.o
|
**.o
|
||||||
|
.build
|
||||||
|
23
Makefile
23
Makefile
@ -1,5 +1,4 @@
|
|||||||
ROM = ../rom.bin
|
ROM = ../rom.bin
|
||||||
MAIN = main.asm6502
|
|
||||||
|
|
||||||
BUILD_DIR = .build
|
BUILD_DIR = .build
|
||||||
|
|
||||||
@ -17,12 +16,24 @@ LDFLAGS = -C linker.conf
|
|||||||
|
|
||||||
-include .dependencies
|
-include .dependencies
|
||||||
|
|
||||||
|
$(BUILD_DIR):
|
||||||
|
mkdir $@
|
||||||
|
|
||||||
default: $(ROM)
|
default: $(ROM)
|
||||||
$(ROM):
|
|
||||||
$(ASM) $(ASMFLAGS) $(ASMDEPFLAGS) $(MAIN) -o $@
|
$(ROM): $(BUILD_DIR)/main.o
|
||||||
|
$(LD) $(LDFLAGS) $< -o $@
|
||||||
|
|
||||||
|
$(BUILD_DIR)/%.o: %.s65 $(BUILD_DIR)
|
||||||
|
$(ASM) $(ASMFLAGS) $(ASMDEPFLAGS) $< -o $@
|
||||||
|
|
||||||
.PHONY = test
|
.PHONY = test
|
||||||
test:
|
test: ../test.bin
|
||||||
|
../test.bin: $(BUILD_DIR)/test.o
|
||||||
# $(VASM) -dotdir -opt-branch -wdc02 -chklabels test.asm6502
|
# $(VASM) -dotdir -opt-branch -wdc02 -chklabels test.asm6502
|
||||||
$(ASM) $(ASMFLAGS) test.asm6502 -o test.o
|
# $(ASM) $(ASMFLAGS) test.asm6502 -o test.o
|
||||||
$(LD) $(LDFLAGS) test.o -o test.bin
|
$(LD) $(LDFLAGS) $(BUILD_DIR)/test.o -o ../test.bin
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -r $(BUILD_DIR)
|
||||||
|
rm $(ROM)
|
||||||
|
155
dht.s65
155
dht.s65
@ -1,155 +0,0 @@
|
|||||||
;********************************************************************************
|
|
||||||
; @module SPI
|
|
||||||
; @type driver
|
|
||||||
; @details
|
|
||||||
; @depends IO-W65C22N
|
|
||||||
;********************************************************************************
|
|
||||||
|
|
||||||
;TODO EVERYTHING
|
|
||||||
DHT_REQUEST_L = $00
|
|
||||||
DHT_REQUEST_H = %01010000 ; = 20480 PHI2 pulses = 20,5 ms at 1 MHz
|
|
||||||
|
|
||||||
DHT_RECV_H = %10011100
|
|
||||||
DHT_RECV_L = %01000000 ; = 40000 PHI2 = 40ms
|
|
||||||
|
|
||||||
; Status Variables, Used to determine what is sent by temp module
|
|
||||||
DHT_STATUS = $400
|
|
||||||
DHT_NONE = 0
|
|
||||||
DHT_WAIT_REQ = 1
|
|
||||||
DHT_WAIT_RESP = 2
|
|
||||||
DHT_RECV = 3
|
|
||||||
DHT_DONE = 4
|
|
||||||
|
|
||||||
DHT_BIT = $401
|
|
||||||
DHT_BIT_ROT = $402
|
|
||||||
|
|
||||||
|
|
||||||
DHT_VALUES = $405 ;
|
|
||||||
DHT_OFFSET = $403
|
|
||||||
DHT_OFF_RH_HIGH = 0 ; offsets to DHT_VALUES
|
|
||||||
DHT_OFF_RH_LOW = 1
|
|
||||||
DHT_OFF_T_HIGH = 2
|
|
||||||
DHT_OFF_T_LOW = 3
|
|
||||||
DHT_OFF_CHECKSUM = 4
|
|
||||||
DHT_OFF_DONE = 5
|
|
||||||
|
|
||||||
|
|
||||||
message_dht: .asciiz "DHT-Request gesendet."
|
|
||||||
dht_wait:
|
|
||||||
ldx #$00
|
|
||||||
dht_wait_:
|
|
||||||
lda message_dht,x
|
|
||||||
sta TO_PRINT,x
|
|
||||||
inx
|
|
||||||
bne dht_wait_
|
|
||||||
jsr lcd_print_clear
|
|
||||||
dht_wait_loop: ; check after every interrpt if dht program is done and then return home
|
|
||||||
lda #'.'
|
|
||||||
jsr _lcd_char
|
|
||||||
wai
|
|
||||||
lda DHT_STATUS
|
|
||||||
cmp #DHT_DONE
|
|
||||||
bne dht_wait_loop
|
|
||||||
|
|
||||||
dht_exit:
|
|
||||||
jsr kb_read
|
|
||||||
cmp #'*'
|
|
||||||
jeq home
|
|
||||||
bra dht_exit
|
|
||||||
jmp return_home
|
|
||||||
|
|
||||||
dht_request: ; send request to sensor
|
|
||||||
sei
|
|
||||||
|
|
||||||
lda #%00000001 ; set PA1-0 to output 0
|
|
||||||
ora DDRA1
|
|
||||||
sta DDRA1
|
|
||||||
lda #(LCD_CLEAR | $00)
|
|
||||||
sta PA1
|
|
||||||
|
|
||||||
; start timer
|
|
||||||
lda #DHT_REQUEST_L
|
|
||||||
sta T1L1
|
|
||||||
lda #DHT_REQUEST_H
|
|
||||||
sta T1H1
|
|
||||||
|
|
||||||
lda #DHT_WAIT_REQ
|
|
||||||
sta DHT_STATUS
|
|
||||||
|
|
||||||
cli
|
|
||||||
jmp dht_wait
|
|
||||||
|
|
||||||
|
|
||||||
dht_request_end:
|
|
||||||
lda #%10000010
|
|
||||||
sta IER2 ; enable Interrupt for CA1
|
|
||||||
lda #%11111110
|
|
||||||
and DDRA1
|
|
||||||
sta DDRA1 ; set PA1-0 to input
|
|
||||||
|
|
||||||
lda #DHT_WAIT_RESP
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dht_response: ; receive response from sensor
|
|
||||||
lda #DHT_RECV
|
|
||||||
sta DHT_STATUS
|
|
||||||
stz DHT_OFFSET
|
|
||||||
lda #7
|
|
||||||
sta DHT_BIT
|
|
||||||
|
|
||||||
dht_recv:
|
|
||||||
; start timer
|
|
||||||
lda #DHT_RECV_L
|
|
||||||
sta T1L1
|
|
||||||
lda #DHT_RECV_H
|
|
||||||
sta T1H1
|
|
||||||
rts
|
|
||||||
|
|
||||||
dht_recv_read:
|
|
||||||
; read PA2
|
|
||||||
lda PA2
|
|
||||||
and #%00000001
|
|
||||||
ldx DHT_BIT
|
|
||||||
beq dht_recv_end
|
|
||||||
dht_recv_rot:
|
|
||||||
rol
|
|
||||||
dex
|
|
||||||
bne dht_recv_rot
|
|
||||||
dht_recv_end:
|
|
||||||
ldy DHT_OFFSET
|
|
||||||
ora DHT_VALUES,y
|
|
||||||
sta DHT_VALUES,y
|
|
||||||
; determine if 8 bits are done
|
|
||||||
ldx DHT_BIT
|
|
||||||
beq dht_recv_next
|
|
||||||
rts
|
|
||||||
dht_recv_next:
|
|
||||||
lda #7
|
|
||||||
sta DHT_BIT
|
|
||||||
inc DHT_OFFSET
|
|
||||||
cmp DHT_OFF_DONE
|
|
||||||
beq dht_display
|
|
||||||
rts
|
|
||||||
|
|
||||||
dht_display:
|
|
||||||
ldx #0
|
|
||||||
dht_display_:
|
|
||||||
lda DHT_VALUES,x
|
|
||||||
sta TO_PRINT,x
|
|
||||||
inx
|
|
||||||
cpx #5
|
|
||||||
bne dht_display_
|
|
||||||
jsr lcd_print_clear
|
|
||||||
rts
|
|
||||||
|
|
||||||
dht_irq:
|
|
||||||
lda DHT_STATUS
|
|
||||||
cmp #DHT_WAIT_REQ
|
|
||||||
beq dht_request_end
|
|
||||||
cmp #DHT_WAIT_RESP
|
|
||||||
beq dht_response
|
|
||||||
cmp #DHT_RECV
|
|
||||||
beq dht_recv
|
|
||||||
rts
|
|
||||||
|
|
@ -3,5 +3,6 @@ MEMORY {
|
|||||||
}
|
}
|
||||||
SEGMENTS {
|
SEGMENTS {
|
||||||
CODE: load = ROM, type = ro;
|
CODE: load = ROM, type = ro;
|
||||||
|
RODATA: load = ROM, type = ro;
|
||||||
RESET_VECTOR: load = ROM, type = ro, start = $FFFA;
|
RESET_VECTOR: load = ROM, type = ro, start = $FFFA;
|
||||||
}
|
}
|
||||||
|
66
main.s65
66
main.s65
@ -1,10 +1,12 @@
|
|||||||
|
.segment "CODE"
|
||||||
.include "system/system.h65"
|
.include "system/system.h65"
|
||||||
.org $8000 ; EEPROM Start Address
|
|
||||||
|
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
; Interrupts
|
; Interrupts
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
nmi:
|
nmi:
|
||||||
|
lda #'%'
|
||||||
|
jsr _lcd_char
|
||||||
rti
|
rti
|
||||||
irq:
|
irq:
|
||||||
; lda IFR2 todo: verify that the line below does the same thing
|
; lda IFR2 todo: verify that the line below does the same thing
|
||||||
@ -15,18 +17,18 @@ irq:
|
|||||||
; jsr lcd_char ;TODO: Remove
|
; jsr lcd_char ;TODO: Remove
|
||||||
jsr kp_read
|
jsr kp_read
|
||||||
rti
|
rti
|
||||||
bbs1 0,irq_keypad
|
; bbs1 0,irq_keypad
|
||||||
lda #'-'
|
lda #'-'
|
||||||
jsr _lcd_char
|
jsr _lcd_char
|
||||||
bbs4 0,irq_dht
|
; bbs4 0,irq_dht
|
||||||
bbs6 0,irq_dht
|
; bbs6 0,irq_dht
|
||||||
rti
|
rti
|
||||||
irq_keypad:
|
irq_keypad:
|
||||||
jsr kp_read
|
jsr kp_read
|
||||||
rti
|
rti
|
||||||
irq_dht:
|
irq_dht:
|
||||||
lda T1L2 ; clear interrupt flag
|
lda IO1 + IO_T1CL ;T1L2 ; clear interrupt flag
|
||||||
jsr dht_irq
|
; jsr dht_irq
|
||||||
rti
|
rti
|
||||||
|
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
@ -34,31 +36,35 @@ irq_dht:
|
|||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
reset:
|
reset:
|
||||||
lda #%11111111
|
lda #%11111111
|
||||||
sta IO2 + IO_DDRA
|
sta IO1 + IO_DDRA
|
||||||
.macro SET_DEBUG_LED_OFF
|
.macro SET_DEBUG_LED_OFF
|
||||||
lda #%00000000
|
lda #%00000000
|
||||||
sta IO2 + IO_RANH
|
sta IO1 + IO_RANH
|
||||||
.endmacro
|
.endmacro
|
||||||
.macro SET_DEBUG_LED_ON
|
.macro SET_DEBUG_LED_ON
|
||||||
lda #%11111111
|
lda #%11111111
|
||||||
sta IO2 + IO_RANH
|
sta IO1 + IO_RANH
|
||||||
.endmacro
|
.endmacro
|
||||||
SET_DEBUG_LED_OFF
|
SET_DEBUG_LED_OFF
|
||||||
jsr lcd_init
|
jsr lcd_init
|
||||||
|
|
||||||
SET_DEBUG_LED_ON
|
SET_DEBUG_LED_ON
|
||||||
|
.repeat 1000
|
||||||
|
nop
|
||||||
|
.endrepeat
|
||||||
|
SET_DEBUG_LED_OFF
|
||||||
; jsr kp_init
|
; jsr kp_init
|
||||||
|
|
||||||
; INIT DHT
|
; ; INIT DHT
|
||||||
lda #%11000010 ; enable interrupt for Timer 1 and CA1 on IO2
|
; lda #%11000010 ; enable interrupt for Timer 1 and CA1 on IO2
|
||||||
sta IER2
|
; sta IER2
|
||||||
lda #%00111111 ; set Timer 1 to interrupt when loaded
|
; lda #%00111111 ; set Timer 1 to interrupt when loaded
|
||||||
and ACR2
|
; and ACR2
|
||||||
sta ACR2
|
; sta ACR2
|
||||||
lda #%00000001 ; set PCR2 bit 0 CA1 pos edge interrupt
|
; lda #%00000001 ; set PCR2 bit 0 CA1 pos edge interrupt
|
||||||
ora PCR2
|
; ora PCR2
|
||||||
sta PCR2
|
; sta PCR2
|
||||||
stz DHT_STATUS
|
; stz DHT_STATUS
|
||||||
|
|
||||||
; enable interrupts
|
; enable interrupts
|
||||||
cli
|
cli
|
||||||
@ -81,7 +87,7 @@ reset:
|
|||||||
cmp #'A'
|
cmp #'A'
|
||||||
jeq printer
|
jeq printer
|
||||||
cmp #'B'
|
cmp #'B'
|
||||||
jeq dht_request
|
; jeq dht_request
|
||||||
cmp #'C'
|
cmp #'C'
|
||||||
beq print_1
|
beq print_1
|
||||||
cmp #'D'
|
cmp #'D'
|
||||||
@ -113,7 +119,7 @@ print_2:
|
|||||||
jsr lcd_print_clear
|
jsr lcd_print_clear
|
||||||
jmp home
|
jmp home
|
||||||
|
|
||||||
.rodata
|
.segment "RODATA"
|
||||||
message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz"
|
message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz"
|
||||||
message_2: .asciiz " Danke fuer eure Aufmerksamkeit ;) "
|
message_2: .asciiz " Danke fuer eure Aufmerksamkeit ;) "
|
||||||
menu:
|
menu:
|
||||||
@ -122,27 +128,25 @@ menu:
|
|||||||
.byte "<C> Text 1 "
|
.byte "<C> Text 1 "
|
||||||
.asciiz "<D> Text 2 "
|
.asciiz "<D> Text 2 "
|
||||||
|
|
||||||
.code
|
.segment "CODE"
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
; Modules
|
; Modules
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
; LCD
|
; LCD
|
||||||
; .include "utility.asm6502"
|
; .include "utility.asm6502"
|
||||||
LCD_IO = IO1
|
LCD_IO = IO1
|
||||||
.include "lcd.asm6502"
|
.include "lcd.s65"
|
||||||
; Keypad Reading
|
; Keypad Reading
|
||||||
KP_IO = IO1
|
KP_IO = IO1
|
||||||
.include "keypad.asm6502"
|
.include "keypad.s65"
|
||||||
; Printer
|
; Printer
|
||||||
.include "printer.asm6502"
|
.include "printer.s65"
|
||||||
; Digital Humidity and Temerature Sensor
|
; Digital Humidity and Temerature Sensor
|
||||||
.include "dht.asm6502"
|
; .include "dht.s65"
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
; reset vector
|
; reset vector
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
|
.segment "RESET_VECTOR"
|
||||||
.rodata
|
|
||||||
.org $fffa
|
|
||||||
.word nmi
|
.word nmi
|
||||||
.word reset
|
.word reset
|
||||||
.word irq
|
.word irq
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
;********************************************************************************
|
||||||
|
; @module SPI
|
||||||
|
; @type driver
|
||||||
|
; @details
|
||||||
|
; @depends IO-W65C22N
|
||||||
|
;********************************************************************************
|
||||||
|
|
||||||
|
;TODO EVERYTHING
|
||||||
DHT_REQUEST_L = $00
|
DHT_REQUEST_L = $00
|
||||||
DHT_REQUEST_H = %01010000 ; = 20480 PHI2 pulses = 20,5 ms at 1 MHz
|
DHT_REQUEST_H = %01010000 ; = 20480 PHI2 pulses = 20,5 ms at 1 MHz
|
||||||
|
|
||||||
@ -5,25 +13,25 @@ DHT_RECV_H = %10011100
|
|||||||
DHT_RECV_L = %01000000 ; = 40000 PHI2 = 40ms
|
DHT_RECV_L = %01000000 ; = 40000 PHI2 = 40ms
|
||||||
|
|
||||||
; Status Variables, Used to determine what is sent by temp module
|
; Status Variables, Used to determine what is sent by temp module
|
||||||
DHT_STATUS = $400
|
DHT_STATUS = $400
|
||||||
DHT_NONE = 0
|
DHT_NONE = 0
|
||||||
DHT_WAIT_REQ = 1
|
DHT_WAIT_REQ = 1
|
||||||
DHT_WAIT_RESP = 2
|
DHT_WAIT_RESP = 2
|
||||||
DHT_RECV = 3
|
DHT_RECV = 3
|
||||||
DHT_DONE = 4
|
DHT_DONE = 4
|
||||||
|
|
||||||
DHT_BIT = $401
|
DHT_BIT = $401
|
||||||
DHT_BIT_ROT = $402
|
DHT_BIT_ROT = $402
|
||||||
|
|
||||||
|
|
||||||
DHT_VALUES = $405 ;
|
DHT_VALUES = $405 ;
|
||||||
DHT_OFFSET = $403
|
DHT_OFFSET = $403
|
||||||
DHT_OFF_RH_HIGH = 0 ; offsets to DHT_VALUES
|
DHT_OFF_RH_HIGH = 0 ; offsets to DHT_VALUES
|
||||||
DHT_OFF_RH_LOW = 1
|
DHT_OFF_RH_LOW = 1
|
||||||
DHT_OFF_T_HIGH = 2
|
DHT_OFF_T_HIGH = 2
|
||||||
DHT_OFF_T_LOW = 3
|
DHT_OFF_T_LOW = 3
|
||||||
DHT_OFF_CHECKSUM = 4
|
DHT_OFF_CHECKSUM = 4
|
||||||
DHT_OFF_DONE = 5
|
DHT_OFF_DONE = 5
|
||||||
|
|
||||||
|
|
||||||
message_dht: .asciiz "DHT-Request gesendet."
|
message_dht: .asciiz "DHT-Request gesendet."
|
||||||
@ -54,16 +62,16 @@ dht_request: ; send request to sensor
|
|||||||
sei
|
sei
|
||||||
|
|
||||||
lda #%00000001 ; set PA1-0 to output 0
|
lda #%00000001 ; set PA1-0 to output 0
|
||||||
ora DDRA1
|
ora IO2 + IO_DDRA
|
||||||
sta DDRA1
|
sta IO2 + IO_DDRA
|
||||||
lda #(LCD_CLEAR | $00)
|
lda #(LCD_CLEAR | $00)
|
||||||
sta PA1
|
sta IO2 + IO_RA
|
||||||
|
|
||||||
; start timer
|
; start timer
|
||||||
lda #DHT_REQUEST_L
|
lda #DHT_REQUEST_L
|
||||||
sta T1L1
|
sta IO2 + IO_T1CL
|
||||||
lda #DHT_REQUEST_H
|
lda #DHT_REQUEST_H
|
||||||
sta T1H1
|
sta IO2 + IO_T1CH
|
||||||
|
|
||||||
lda #DHT_WAIT_REQ
|
lda #DHT_WAIT_REQ
|
||||||
sta DHT_STATUS
|
sta DHT_STATUS
|
||||||
@ -74,10 +82,10 @@ dht_request: ; send request to sensor
|
|||||||
|
|
||||||
dht_request_end:
|
dht_request_end:
|
||||||
lda #%10000010
|
lda #%10000010
|
||||||
sta IER2 ; enable Interrupt for CA1
|
sta IO2 + IO_IER ; enable Interrupt for CA1
|
||||||
lda #%11111110
|
lda #%11111110
|
||||||
and DDRA1
|
and IO2 + IO_DDRA
|
||||||
sta DDRA1 ; set PA1-0 to input
|
sta IO2 + IO_DDRA ; set PA1-0 to input
|
||||||
|
|
||||||
lda #DHT_WAIT_RESP
|
lda #DHT_WAIT_RESP
|
||||||
|
|
||||||
@ -93,14 +101,14 @@ dht_response: ; receive response from sensor
|
|||||||
dht_recv:
|
dht_recv:
|
||||||
; start timer
|
; start timer
|
||||||
lda #DHT_RECV_L
|
lda #DHT_RECV_L
|
||||||
sta T1L1
|
sta IO2 + IO_T1CL
|
||||||
lda #DHT_RECV_H
|
lda #DHT_RECV_H
|
||||||
sta T1H1
|
sta IO2 + IO_T1CH
|
||||||
rts
|
rts
|
||||||
|
|
||||||
dht_recv_read:
|
dht_recv_read:
|
||||||
; read PA2
|
; read PA2
|
||||||
lda PA2
|
lda IO2 + IO_RA
|
||||||
and #%00000001
|
and #%00000001
|
||||||
ldx DHT_BIT
|
ldx DHT_BIT
|
||||||
beq dht_recv_end
|
beq dht_recv_end
|
||||||
|
@ -14,6 +14,3 @@ After assembling it, the binary is loaded onto the EEPROM using [my *eeprom.py*
|
|||||||
- Ringbuffer for pressed keys.
|
- Ringbuffer for pressed keys.
|
||||||
|
|
||||||
> It's not much, but it's honest work.
|
> It's not much, but it's honest work.
|
||||||
|
|
||||||
## Debug-Utility (with Raspberry Pi 4)
|
|
||||||
`monitor.py` is a python program to monitor the address-bus, data-bus and the read-write pin of the computer. It prints the current address and data in binary and hexadecimal on each clock cycle.
|
|
||||||
|
@ -9,41 +9,100 @@
|
|||||||
INCLUDE_IOW65C22 = 1
|
INCLUDE_IOW65C22 = 1
|
||||||
|
|
||||||
; IO-CHIPS OFFSETS FOR PINS FROM BASE ADDRESS
|
; IO-CHIPS OFFSETS FOR PINS FROM BASE ADDRESS
|
||||||
IO_RB = $0
|
IO_RB = $0 ; Register B (ORB/IRB)
|
||||||
IO_RA = $1
|
IO_RA = $1 ; Register A (ORA/IRA)
|
||||||
IO_DDRB = $2
|
IO_DDRB = $2 ; Data Direction Register B
|
||||||
IO_DDRA = $3
|
IO_DDRA = $3 ; Data Direction Register A
|
||||||
IO_T1CL = $4
|
IO_T1CL = $4 ; Timer 1 Counter Low/High
|
||||||
IO_T1CH = $5
|
IO_T1CH = $5
|
||||||
IO_T1LL = $6
|
IO_T1LL = $6 ; Timer 1 Latch Low/High
|
||||||
IO_T1LH = $7
|
IO_T1LH = $7
|
||||||
IO_T2CL = $8
|
IO_T2CL = $8 ; Timer 2 Counter Low/High
|
||||||
IO_T2CH = $9
|
IO_T2CH = $9
|
||||||
IO_SR = $a
|
IO_SR = $a ; Shift Register
|
||||||
IO_ACR = $b
|
IO_ACR = $b ; Auxiliary Control Register
|
||||||
IO_PCR = $c
|
; ACR Masks
|
||||||
IO_IFR = $d
|
IO_ACR_MASK_PA = %00000001 ;
|
||||||
IO_IER = $e
|
IO_ACR_MASK_PB = %00000010 ;
|
||||||
|
IO_ACR_MASK_SR = %00011100 ;
|
||||||
|
IO_ACR_MASK_T2 = %00100000 ;
|
||||||
|
IO_ACR_MASK_T1 = %11000000 ;
|
||||||
|
; SR Modes
|
||||||
|
IO_ACR_SR_DISABLE = %00000000 ; Disabled
|
||||||
|
IO_ACR_SR_SIN_T2 = %00000100 ; Shift in under control of T2
|
||||||
|
IO_ACR_SR_SIN_PHI2 = %00001000 ; Shift in under control of PHI2
|
||||||
|
IO_ACR_SR_SIN_PHIE = %00001100 ; Shift in under control of external clock
|
||||||
|
IO_ACR_SR_SOUT_FREE_T2 = %00010000 ; Shift out free running at T2 rate
|
||||||
|
IO_ACR_SR_SOUT_T2 = %00010100 ; Shift out under control of T2
|
||||||
|
IO_ACR_SR_SOUT_PHI2 = %00011000 ; Shift out under control of PHI2
|
||||||
|
IO_ACR_SR_SOUT_PHIE = %00011100 ; Shift out under control of external clock
|
||||||
|
; T1 Modes
|
||||||
|
IO_ACR_T1_IRQ_LOAD = %00000000 ; Timed interrupt each time T1 is loaded
|
||||||
|
IO_ACR_T1_IRQ_CONT = %01000000 ; Continuous interrupts
|
||||||
|
IO_ACR_T1_IRQ_LOAD_PB7 = %10000000 ; Timed interrupt each time T1 is loaded - PB7 One Shot output
|
||||||
|
IO_ACR_T1_IRQ_CONT_PB7 = %11000000 ; Continuous interrupts - PB7 Square wave output
|
||||||
|
IO_PCR = $c ; Peripheral Control Register
|
||||||
|
; PCR Masks
|
||||||
|
IO_PCR_MASK_CA1 = %00000001 ;
|
||||||
|
IO_PCR_MASK_CA2 = %00001110 ;
|
||||||
|
IO_PCR_MASK_CB1 = %00010000 ;
|
||||||
|
IO_PCR_MASK_CB2 = %11100000 ;
|
||||||
|
; CA1 Modes
|
||||||
|
IO_PCR_CA1_IN_AE = %00000000 ; Input-negative active edge
|
||||||
|
IO_PCR_CA1_IP_AE = %00000001 ; Input-positive active edge
|
||||||
|
; CA2 Modes
|
||||||
|
IO_PCR_CA2_IN_AE = %00000000 ; Input-negative active edge
|
||||||
|
IO_PCR_CA2_IN_AE_IRQ_IND= %00000010 ; Independent interrupt input-negative edge
|
||||||
|
IO_PCR_CA2_IP_AE = %00000100 ; Input-positive active edge
|
||||||
|
IO_PCR_CA2_IP_AE_IRQ_IND= %00000110 ; Independent interrupt input-positive edge
|
||||||
|
IO_PCR_CA2_IN_HANDSHAKE = %00001000 ; Handshake output
|
||||||
|
IO_PCR_CA2_IN_PULSE_OUT = %00001010 ; Pulse output
|
||||||
|
IO_PCR_CA2_IN_LOW_OUT = %00001100 ; Low output
|
||||||
|
IO_PCR_CA2_IN_HIGH_OUT = %00001110 ; High output
|
||||||
|
; CB1 Modes
|
||||||
|
IO_PCR_CB1_IN_AE = %00000000 ; Input-negative active edge
|
||||||
|
IO_PCR_CB1_IP_AE = %00010000 ; Input-positive active edge
|
||||||
|
; CB2 Modes
|
||||||
|
IO_PCR_CB2_IN_AE = %00000000 ; Input-negative active edge
|
||||||
|
IO_PCR_CB2_IN_AE_IRQ_IND= %00100000 ; Independent interrupt input-negative edge
|
||||||
|
IO_PCR_CB2_IP_AE = %01000000 ; Input-positive active edge
|
||||||
|
IO_PCR_CB2_IP_AE_IRQ_IND= %01100000 ; Independent interrupt input-positive edge
|
||||||
|
IO_PCR_CB2_IN_HANDSHAKE = %10000000 ; Handshake output
|
||||||
|
IO_PCR_CB2_IN_PULSE_OUT = %10100000 ; Pulse output
|
||||||
|
IO_PCR_CB2_IN_LOW_OUT = %11000000 ; Low output
|
||||||
|
IO_PCR_CB2_IN_HIGH_OUT = %11100000 ; High output
|
||||||
|
|
||||||
|
IO_IFR = $d ; Interrupt Flag Register
|
||||||
|
; IFR bits
|
||||||
|
IO_IFR_CA2 = 0
|
||||||
|
IO_IFR_CA1 = 1
|
||||||
|
IO_IFR_SR = 2
|
||||||
|
IO_IFR_CB2 = 3
|
||||||
|
IO_IFR_CB1 = 4
|
||||||
|
IO_IFR_T2 = 5
|
||||||
|
IO_IFR_T1 = 6
|
||||||
|
IO_IFR_IRQ = 7
|
||||||
|
IO_IER = $e ; Interrupt Enable Register
|
||||||
IO_RANH = $f ; no handshake
|
IO_RANH = $f ; no handshake
|
||||||
|
|
||||||
; TODO: leave?
|
; TODO: leave?
|
||||||
.struct VIA_Pins
|
; .struct VIA_Pins
|
||||||
RB .byte ; $0
|
; RB .byte ; $0
|
||||||
RA .byte ; $1
|
; RA .byte ; $1
|
||||||
DDRB .byte ; $2
|
; DDRB .byte ; $2
|
||||||
DDRA .byte ; $3
|
; DDRA .byte ; $3
|
||||||
T1CL .byte ; $4
|
; T1CL .byte ; $4
|
||||||
T1CH .byte ; $5
|
; T1CH .byte ; $5
|
||||||
T1LL .byte ; $6
|
; T1LL .byte ; $6
|
||||||
T1LH .byte ; $7
|
; T1LH .byte ; $7
|
||||||
T2CL .byte ; $8
|
; T2CL .byte ; $8
|
||||||
T2CH .byte ; $9
|
; T2CH .byte ; $9
|
||||||
SR .byte ; $a
|
; SR .byte ; $a
|
||||||
ACR .byte ; $b
|
; ACR .byte ; $b
|
||||||
PCR .byte ; $c
|
; PCR .byte ; $c
|
||||||
IFR .byte ; $d
|
; IFR .byte ; $d
|
||||||
IER .byte ; $e
|
; IER .byte ; $e
|
||||||
RANH .byte ; $f ; no handshake
|
; RANH .byte ; $f ; no handshake
|
||||||
.endstruct
|
; .endstruct
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
.error "IO-W65C22 module is not included"
|
.error "IO-W65C22 module is not included"
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
.include "utility.asm6502"
|
.include "utility.h65"
|
||||||
|
|
||||||
|
|
||||||
; RAM VARIABLES
|
; RAM VARIABLES
|
||||||
|
@ -40,8 +40,8 @@ ARG13 = $1d
|
|||||||
ARG14 = $1e
|
ARG14 = $1e
|
||||||
ARG15 = $1f
|
ARG15 = $1f
|
||||||
|
|
||||||
.include "io_W65C22.asm6502"
|
.include "io_W65C22.h65"
|
||||||
.include "utility.asm6502"
|
.include "utility.h65"
|
||||||
|
|
||||||
; RETURN VALUE
|
; RETURN VALUE
|
||||||
; in a
|
; in a
|
||||||
@ -50,29 +50,29 @@ IO1 = $6000
|
|||||||
IO2 = $7000
|
IO2 = $7000
|
||||||
|
|
||||||
; struct method
|
; struct method
|
||||||
.org $6000
|
; .org $6000
|
||||||
VIA1: .tag VIA_Pins
|
; VIA1: .tag VIA_Pins
|
||||||
.org $7000
|
; .org $7000
|
||||||
VIA2: .tag VIA_Pins
|
; VIA2: .tag VIA_Pins
|
||||||
|
|
||||||
; IO-1
|
; ; IO-1
|
||||||
PB1 = $6000
|
; PB1 = $6000
|
||||||
PA1 = $6001
|
; PA1 = $6001
|
||||||
DDRB1 = $6002
|
; DDRB1 = $6002
|
||||||
DDRA1 = $6003
|
; DDRA1 = $6003
|
||||||
T1L1 = $6004
|
; T1L1 = $6004
|
||||||
T1H1 = $6005
|
; T1H1 = $6005
|
||||||
; IO-2
|
; ; IO-2
|
||||||
PB2 = $7000
|
; PB2 = $7000
|
||||||
PA2 = $7001
|
; PA2 = $7001
|
||||||
DDRB2 = $7002
|
; DDRB2 = $7002
|
||||||
DDRA2 = $7003
|
; DDRA2 = $7003
|
||||||
T1L2 = $7004
|
; T1L2 = $7004
|
||||||
T1H2 = $7005
|
; T1H2 = $7005
|
||||||
ACR2 = $700b
|
; ACR2 = $700b
|
||||||
PCR2 = $700c
|
; PCR2 = $700c
|
||||||
IFR2 = $700d
|
; IFR2 = $700d
|
||||||
IER2 = $700e
|
; IER2 = $700e
|
||||||
|
|
||||||
|
|
||||||
.endif ; include guard
|
.endif ; include guard
|
||||||
|
41
test.s65
41
test.s65
@ -1,4 +1,4 @@
|
|||||||
.include "system/system.asm6502"
|
.include "system/system.h65"
|
||||||
.segment "CODE"
|
.segment "CODE"
|
||||||
|
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
@ -7,23 +7,8 @@
|
|||||||
nmi:
|
nmi:
|
||||||
rti
|
rti
|
||||||
irq:
|
irq:
|
||||||
nop
|
.repeat 20
|
||||||
nop
|
.endrepeat
|
||||||
nop
|
|
||||||
nop
|
|
||||||
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
|
|
||||||
nop
|
|
||||||
nop
|
|
||||||
rti
|
rti
|
||||||
|
|
||||||
;********************************************************************************
|
;********************************************************************************
|
||||||
@ -34,17 +19,29 @@ reset:
|
|||||||
; setup io2 bank a 1-3
|
; setup io2 bank a 1-3
|
||||||
lda #%11111111
|
lda #%11111111
|
||||||
sta IO1 + IO_DDRA
|
sta IO1 + IO_DDRA
|
||||||
|
sta IO1 + IO_DDRB
|
||||||
|
|
||||||
@loop:
|
@loop:
|
||||||
lda #%00000000
|
lda #%00000000
|
||||||
sta IO1 + IO_RANH
|
sta IO1 + IO_RA
|
||||||
.repeat 3
|
.repeat 3
|
||||||
nop
|
nop
|
||||||
.endrepeat
|
.endrepeat
|
||||||
lda #%11111111
|
lda #%11111111
|
||||||
sta IO1 + IO_RANH
|
sta IO1 + IO_RA
|
||||||
|
.repeat 15
|
||||||
|
nop
|
||||||
|
.endrepeat
|
||||||
|
|
||||||
|
lda #%00000000
|
||||||
|
sta IO1 + IO_RB
|
||||||
.repeat 5
|
.repeat 5
|
||||||
nop
|
nop
|
||||||
|
.endrepeat
|
||||||
|
lda #%11111111
|
||||||
|
sta IO1 + IO_RB
|
||||||
|
.repeat 10
|
||||||
|
nop
|
||||||
.endrepeat
|
.endrepeat
|
||||||
bra @loop
|
bra @loop
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user