Hello all,
I've been trying to build a very simple 65C02 system as a learning project, but I must be misinterpreting or misunderstanding something.
My goal is to use a WDC 65C02 to run a program stored in a 28C256, that uses a 74HCT373 to light eight LEDs in sequence, D7 to D0 (i.e. one LED lit at a time). What I get instead is each LED lighting in sequence and staying lit.
I've attached schematics for the main portion and for the memory decode section. My apologies if they are confusing. I've omitted the LEDs, power connections, and clock as they are trivial.
Schematic notes:
- The address bus joins the CPU to ROM via A0-A7. The upper eight lines are not used and the corresponding lines on the ROM chip are tied high, as the program is entirely contained in the highest page ($FFxx).
- I'm cheating a bit with memory decoding by using RWB instead of A15 to determine whether the system should select ROM or the '373. My reason for doing this is because the program reads only from ROM and "writes" only to the '373.
- CLOCK is generated by a oscillator-to-74ABT74 circuit. Frequency is 0.5 MHz.
- RESET is controlled by a DS1813.
- OUT_0-OUT_7 are just LEDs, each with a 470 Ω resistor.
(Btw, I'm using TTL because those were the parts I had. Further development would use 74HC logic.)
Here is the program I wrote. I used straight machine code because the code was small enough (33 bytes) to allow me to put off learning an assembler. But I've hand-assembled--accurately, I hope--the bytes into opcodes and operands:
Code:
// Program start = $FF00
0xA9, 0x00, // START: LDA #00 ; clear accumulator
0x38, // SEC ; prepare carry bit.
0x6A, // NEXT_LED: ROR A ; march the ant one space right
0xA0, 0x00, // SET_Y: LDY #00 ; inner delay loop prep
0xA2, 0x00, // SET_X: LDX #00 ; inner delay loop prep
0x8D, 0x00, 0x10, // STA $1000 ; write bit pattern to '373 and latch. Address is irrelevant
; since we use RWB to select the chip.
0xE8, // NEXT_X: INX ; delay loop
0xF0, 0x03, // BEQ NEXT_Y
0x4C, 0x0B, 0xFF, // JMP NEXT_X
0xC8, // NEXT_Y: INY
0xF0, 0x03, // BEQ CHK_0
0x4C, 0x06, 0xFF, // JMP SET_X
0x89, 0x00, // CHK_0 BIT #00 ; if the ant has marched all the way to the carry bit
0xF0, 0x03, // BEQ NO_BLANK ; then restart.
0xFC, 0x03, 0xFF, // JMP NEXT_LED ; otherwise keep marching.
0xFC, 0x00, 0xFF, // NO_BLANK: JMP START