Sometimes when i’m writing code i want to know what’s happening. For example when i’m working on the display, there is maybe no output. With the above example i can write to address $01F0 (example address), and it will display on the 7 Segment displays.
Upperleft PLD is my address decoder, which has been running for a while now.
Secondary PLD adds the rest of the Addressbus lines, and gives me the opportunity to select in a range of 16 addresses, using jumpers/
The two smaller PLD’s latch the databus data when addressed. AND decodes a nibble to 7-Segment output for 0-9A-F. (There are apparently no chips available which do A-F)
I’m going to add the PLD code when everything works. Let me know if you like the idea.
No more sync issues! (see post https://www.henriaanstoot.nl/2022/10/19/composite-video-with-atmega328p/ )
There are some duplicate characters, the input device below does not have a proper debounce method.
My temporary input device (note hex 21 is a “!” character)
No need to fix the debounce, the dipswitches are temporary. This will be controlled by the VIA 6522 chip.
UPDATE 20221108 (Connected to second VIA)
PORTB = $5000
PORTA = $5001
DDRB = $5002
DDRA = $5003
clock = $e0
E = %10000000
RW = %01000000
RS = %00000000
.org $0200
reset:
ldx #$ff
txs
lda #%11111111 ; Set all pins on port B to output
sta DDRB
lda #%10000000 ; Set top pin on port A to output
sta DDRA
lda #$00 ; reset bit
sta PORTA
sta clock
ldx #0
print:
lda message,x
beq printborder
jsr print_char
inx
jmp print
loop:
jmp loop
message:
.db 0x01,0x04,0x0C,0x0E,0x10,0x0F,0x08
.db 0x05,0x0a,0x0a
.db 0x05,0x0b,0x0b
.asc "Composite Video 6502 - 20221108"
.db 0x0E,0x11,0x0F,0x0C
.asciiz " With 2 pixels "
waitloop:
pha
tya
pha
ldy #$ff
back:
dey
bne back
pla
tay
pla
rts
print_char:
sta PORTB
jsr waitloop
jsr waitloop
lda clock
eor #%10000000
sta clock
sta PORTA
jsr waitloop
lda clock
eor #%10000000
sta PORTA
jsr waitloop
rts
Control codes as from : http://searle.x10host.com/MonitorKeyboard/index.html
Video display control codes:
Hex (Decimal) and meaning
01 (01) - Cursor home (Standard ASCII)
02 (02) - Define cursor character (2nd byte is the curs character, or 00 to turn off) <--New for 3.0
03 (03) - Cursor blinking
04 (04) - Cursor solid
05 (05) - Set graphics pixel (next two bytes = x,y) <--New for 3.0
06 (06) - Reset graphics pixel (next two bytes = x,y) <--New for 3.0
08 (08) - Backspace (Standard ASCII)
09 (09) - Tab (Standard ASCII)
0A (11) - Linefeed (Standard ASCII)
0C (12) - Clear screen (Standard ASCII)
0D (13) - Carriage return (Standard ASCII)
0E (14) - Set column 0 to 79 (2nd byte is the column number) or 0 to 39 for a 40 char line
0F (16) - Set row 0 to 24 (2nd byte is the row number)
10 (16) - Delete start of line
11 (17) - Delete to end of line
12 (18) - Delete to start of screen
13 (19) - Delete to end of screen
14 (20) - Scroll up
15 (21) - Scroll down
16 (22) - Scroll left
17 (23) - Scroll right
18 (24) - Set font attribute for the current line (see elsewhere on this page for details) <--New for 3.0
1A (26) - Treat next byte as a character (to allow PC DOS char codes 1 to 31 to be displayed on screen)
1B (27) - ESC - reserved for ANSI sequences
1C (28) - Cursor right
1D (29) - Cursor Left
1E (30) - Cursor up
1F (31) - Cursor down
20 (32) to 7E (126) - Standard ASCII codes
7F (127) - Delete
80 (128) to FF (255) - PC (DOS) extended characters
I started to get some composite video generated with a arduino for my 6502 project.
UPDATE: 20221021
It is based on Grant Searle’s design, and yesterday I had some signals on my scope which looked like a screen with a character. But my monitor would not recognize a usable signal.
Today I tried a second version and another set of chips and crystals.
It looks like a signal, but I can’t see a clock pulse from the crystal?! So .. how?
Maybe I used a bad power supply. And killed something?
UPDATE: 20221021
After switching to another power supply, and checking the atmega328p fuses again (also wrong) .. at least SOME success!
Still a little sync problem, but i’ve got a blinking cursor!
There are a lot of old develop boards for all kinds for cpu’s.
These where build to learn machine code programming. Mostly made in the 80’s, and based on populair cpu’s at that time.
I own a some of these SDK’s (System Design Kits)
8085 – SDK85 i bought recently 8085 CPU
Microprofessor-1 (MPF-1) Z80 CPU
And my own 680x based computer
Most of these use a keyboard scanner which is also connected to 7 segment displays.
The way they work is practically the same. There is a VIA or PIA. Versitile interface adaptor, or Peripheral interface adaptor. These have two times 8 bits to control devices. When using 4 bits and convert these to 16 lines by using a 75ls145 for example. If you put a counter on those 4 bits, you sequently activate 1 of 16 lines. These lines you can use to scan a keyboard matrix OR display a character on a 7 segment display. These display’s won’t hold the data (and show the character) when not activated. The trick is to update de display fast enough so you don’t see the flickering on/off.
Activate a line and read a byte with the VIA = Reading keyboard row Activate a line and write a byte with the VIA = Display on a segment
These VIA/PIA’s where made with specific timings to match the CPU. 6522/6820/8255
Below you see some different implementations of these keyboard/display combo’s
Thaler 6502 kit
Microprofessor MPF-1 kit (ignore red circle)
SDK85 kit
Eltec 6800
My version using darlington arrays (ULN2003)
When looking at the 8085 version you see transistors being a ULN2003 is a chip with those transistors/amplification enclosed. It doesn´t draw much current from the bus, and diodes protect the way the current flows.
Buzzer and led on VIA 2, blinky and sound timed by the internal timers of the 6522
ACIA testing still going on, writing software
Mini matrix keyboard removed, and used the temporary cursor buttons for the test with a rom which allows for a 8bits upload method using a arduino and the 6522. (I’m working on the big keyboard)
Work in progress code
PORT2B = $5000 ; VIA PORTB
PORT2A = $5001 ; VIA PORTA
DDR2B = $5002 ; Data direction register
DDR2A = $5003 ; Data direction register
PORTB = $6000 ; display
PORTA = $6001 ; control display + matrix keyboard
DDRB = $6002 ; data direction register
DDRA = $6003 ; data direction register
SID = $7000 ; sid base address
E = %10000000 ; enable bit
RW = %01000000 ; RW bit
RS = %00100000 ; Register Select bit
HOME = %00000010 ; VIA PORTB HOME command
DADDR = %00010000 ; VIA DADDRESS
LINENO = $0200 ; temp address linenumber (move to other location)
NEXTLINE = 40 ; 2x16 Chars but internally 40
.org $8000
reset:
ldx #$ff
txs ; reset stack
; ###################################################
; # DISPLAY CONTROL #
; ###################################################
; VIA Setup
lda #%11111111 ; Set all pins on port B to output
sta DDRB
lda #%11100000 ; Set top 3 pins on port A to output
sta DDRA
; DISPLAY Setup
lda #%00111000 ; Set 8-bit mode; 2-line display; 5x8 font
jsr lcd_instruction
lda #%00001110 ; Display on; cursor on; blink off
jsr lcd_instruction
lda #%00000110 ; Increment and shift cursor; don't shift display
jsr lcd_instruction
lda #$00000001 ; Clear display
jsr lcd_instruction
; ###################################################
; # PRINT MESSAGE LINE NO 0 #
; ###################################################
lda #0 ; set line number
sta LINENO ; store for subroutine
jsr gotoline ; move cursor
ldx #0 ; message index pointer
print:
lda message0,x ; start of message
beq nextprint ; stop when null in message (asciiz <- Zero padded)
jsr print_char ; print char
inx ; incr index
jmp print ; resume print
; ###################################################
; # PRINT MESSAGE LINE NO 1 #
; ###################################################
nextprint:
lda #1 ; set line number
sta LINENO ; store
jsr gotoline
ldx #0 ; index pointer
print2:
lda message1,x ; absolute address message + x in A
beq sidsound ; if x is 0, end of message
jsr print_char ; jump subroutine
inx ; increment x
jmp print2 ; loop print2
; ###################################################
; # SID SOUND #
; ###################################################
sidsound:
lda #0
sta SID+$5 ; attack/decay duration
lda #250
sta SID+$6 ; sustain level/release duration
lda #$95 ; frequency voice 1 low byte
sta SID+$0
lda #$44 ; frequency voice 1 high byte
sta SID+$1
lda #%00100001 ; sawtooth + gate
sta SID+$4 ; control register voice 1
lda #$0f ; filter mode and volume (bits 3-0 main volume)
sta SID+$18 ; filter mode and volume
; ###################################################
; # 2ND VIA #
; ###################################################
lda #%11111111 ; set port A output
sta DDR2A
lda #%11111111 ; all ones!
sta PORT2A
; ###################################################
lda #%11111111 ; set port A output
sta DDR2A
lda #%11111111 ; all ones!
sta PORT2A
; ###################################################
; # MAIN PROGRAM LOOP #
; ###################################################
loop:
jmp loop
; 1234567812345678
message0: .asciiz "VIA 1,2 SID TEST"
message1: .asciiz " FASH 2022 "
; ###################################################
; # ONLY SUBROUTINES #
; ###################################################
; ###################################################
; # Subroutine gotoline #
; # Moves character placement position on display #
; # Needs : $LINENO ADDRESS #
; # Exit values : - #
; # Destroys registers: - #
; ###################################################
gotoline:
pha ; store a
txa
pha ; store x
ldx LINENO
lda #HOME ; cursor down
jsr lcd_instruction
lda #$80
nextline:
ldx LINENO
cpx #00
beq endnextlines
loopline:
adc #40
jsr lcd_instruction
dex
stx LINENO
jmp nextline
endnextlines:
pla ; pop a
tax ; a to x
pla ; pop a
rts
; ###################################################
; # LCD SUBROUTINES #
; ###################################################
lcd_wait:
pha
lda #%00000000 ; Port B is input
sta DDRB
lcdbusy:
lda #RW
sta PORTA
lda #(RW | E)
sta PORTA
lda PORTB
and #%10000000
bne lcdbusy
lda #RW
sta PORTA
lda #%11111111 ; Port B is output
sta DDRB
pla
rts
lcd_instruction:
jsr lcd_wait
sta PORTB
lda #0 ; Clear RS/RW/E bits
sta PORTA
lda #E ; Set E bit to send instruction
sta PORTA
lda #0 ; Clear RS/RW/E bits
sta PORTA
rts
print_char:
jsr lcd_wait
sta PORTB
lda #RS ; Set RS; Clear RW/E bits
sta PORTA
lda #(RS | E) ; Set E bit to send instruction
sta PORTA
lda #RS ; Clear E bits
sta PORTA
rts
nmi:
rti
irq:
rti
.org $fffa
.word nmi
.word reset
.word irq
; .word $0000
In this case designed for my 6502, but it is a generic setup.
I it just a dual 16key matrix decoder merged together. You can probably use this with raspberries, arduinos etc.
I wanted to use 74C923 but these are nowhere to be found. And even then, the number of keys wil be 20. So i am tying together two 74C922 using some logic in a PLD.
First draft
It wil be something like above. Using the data availabe signal i can combine both 16key matrixes. (In theory .. it is all untested)
New address decoder in place! Connected RAM/ROM/SID/VIA1/VIA2 and ACIA
ROM
8000-FFFF
SID
7000-700F (sound)
VIA1
6000-60xx (Hex key matrix)
ACIA
6800-68xx (serial)
VIA2
5000-50xx (led test at the moment)
RAM
0000-3FFF
To plan: Bigger maxtrix keyboard and other displays
ACIA 6551
Got a serial connection working between the 6502 and my linux machine!
3 line serial – no hardware handshake
At the moment when a reset occurs , hello is being printed. Text typed in the minicom terminal, is echo-ed back and displayed on the LCD display.
Things learned: Do not trust internet schematics blindly!
The crystal used for the ACIA (pin 6/7 1.8432Mhz needs a 1M ohm resistor parallel over the crystal, and a 30nF capacitor from pin 7 to GND
When using a terminal emulator, and using 3 wires. Disable hardware handshake.
Keyboard rewired.
What didn´t work as planned:
New amplifier schematic for the SID. There is too much noise.
Amplifier with a LM628
Bought a dual power supply (5V and 12V). But this one has a lot of signal noise on the SID part and even my battlestation speakers!
LED test 2nd via
PORTB = $5000 ; VIA PORTB
PORTA = $5001 ; VIA PORTA
DDRB = $5002 ; Data direction register
DDRA = $5003 ; Data direction register
LED = %10000000
.org $8000
reset:
lda #%11100000 ; Set top 3 pins on port A to output
sta DDRA
lda LED
sta PORTA
loop: ; done loop until doomsday
jmp loop
irq:
nmi:
.org $fffa
.word nmi
.word reset
.word irq
ACIA part
ACIA_RX = $6800
ACIA_TX = $6800
ACIA_STATUS = $6801
ACIA_COMMAND = $6802
ACIA_CONTROL = $6803
lda #$00
sta ACIA_STATUS
lda #$0b
sta ACIA_COMMAND
lda #$1f
sta ACIA_CONTROL
"If something is worth doing, it's worth overdoing."