Introduction and 1541 problem
Posted: Wed May 09, 2007 11:35 pm
Hi, I have been lurking for a little while and reading a load of very interesting posts. It encouraged me to start my own project which I need to explain somewhat I think. Excuse the rambling description - this does take some explaining!
Basically I am on a Bender. As in the robot kind. From Futurama. I am building a full sized Bender robot with a beer brewing barrel inside him. That was simple enough but never being content with nice, easy projects I decided it would be cool to make him talk. I decided it would be even cooler and in keeping with a joke on the show if Benders 'brain' was 6502 based.
I have built a small circuit which is basically a binary counter hooked into some ROM chips programmed with audio samples. I am using 27c2001/27c020s. The counter counts up through the ROMs address lines clocking out the data which is then fed into a latch and finally a 8 bit R2R D to A. All very crude but actually fairly effective. I built the circuit such that I can test it seperately with a 555 providing clock pulses. This works now and I can play audio from the chip.
The next step is making all this micro controlled. I could make a 6502 SBC from scratch to drive it but as I have a 1541 disk drive here (that someone gave me over 10 years ago) I decided to hack that instead to see if the idea will work. What I have done is make an adaptor that plugs in where the 6522 VIA that controls the drive mechanism goes (UC2 which is at 1C00h). This adaptor allows through all the pins except all the port A and B pins and the CA1/2 CB1/2 pins. Those are then broken out and wired through to my circuit.
My idea is to reprogram the 1541 ROM and control the VIA to drive my circuit. I use the VIAs onboard timer to generate the clock signal I need to clock my audio circuit (at 16khz). I use 4 bits on one of the ports to drive the top four address bits of each of my memory chips. Using 4 bits this way means I can access the audio in one second blocks. I use the other four bits to do chip selection of each of my audio ROM chips. Clocking audio at at 16kHz allows me 16 seconds of audio per chip and I can have up to 10 chips (using a 1 into 10 decoder for the chip select).
I was going to get clever and have lookup tables in the audio chips so I could read them to see what samples there were and where but as the audio ROM isn't hooked to the data bus (only the latch) I decided against that. I will just hardcode the starting addresses of the samples into the controlling program. Once I get the thing working I can't see wanting to change the samples anyway.
I am currently trying to get a simple program running on the hacked drive board just to get my head around 6502 programming and to see if I can setp the VIA how I need it. I am using 27c64 ROMS in place of the drives 2364 using a pin adaptor. There may be something odd about these ROMS. They are a Fujitsu part and need a 21v programming level. They might be a 6 volt part and that may be causing my problems. I did also use one of the 27c2001s though (ignoring the upper address pins) as a test and get the same results.
Basically I have written a little program that should simply loop around setting and resetting the VIA port pins. I have a small handheld scope that is good enough to show me pins wiggling up and down (but not much more). What seems to be happening is my code is running I think. I can see the address lines on the ROM changing and also see the data being switched out. I have no way to telling what the data is of course, just that it is there. When I look at the 1-10 chip select on the 1541 though it isn't selecting the VIA at all. Only the output for number 1 is changing. I expect to see the CS2 chip select pins on the VIA toggling but I don't.
I am new to 6502 coding although I have played with PICs in the past (in fact I have made the same circuit before using a PIC as the controller and that worked fine). I am using the Kowalski 6502 simulator/assembler to write and test the code. In the simulator it works fine. I can see the memory at 1C00h and 1C01h toggle.
If I am understanding the 1541 circuit and disassembly correctly the ROM chip I am replacing is at address E000h to FFFFh. This is UB4 on the board (closest to the heatsink). The VIA is UC2 and at address 1C00h.
I am not sure of my code so I have included it here. Once assembled I save it as a binary take the hex code and open it in Visual Studio. I remove all the blanks at the start (0000h to DFFFh) so the code starts at 0000h and the reset vector is at 1FFCh and I program this into my ROM chip. Once on the board everything should then match up fine (code starting at E000h and reset at FFFCh).
I can't understand why I am not seeing the VIA chip being selected. If the addresses are clocking through OK as they do on the simulator then the VIA ports should be alternating 1 and 0s. I am sure I have missed something blindingly obvious or am doing something silly which is why it isn't working. I just need someone to slap me on the head and point it out!
I may in the mean time start building a new board from scratch and just use the chips off the 1541 in that. Be a lot neater and smaller but using the 1541 is a good test for now.
Simon
Here is the code (formatting probably messed up posting it here):
rom_start = $E000
reset = $Fffc
via = $1c00
via_b = via + 0
via_a = via + 1
via_bdir = via + 2
via_adir = via + 3
.ORG rom_start
LDA #$FF ; Load acc with FFh
STA via_bdir ; Set port b all output
STA via_adir ; Set port a all output
loop
LDA #$AA ; Data
STA via_b ; Load data on port b
STA via_a ; Load data on port a
LDA #$55 ; Data
STA via_b ; Load data on port b
STA via_a ; Load data on port a
JMP loop
.ORG reset ; Reset vector
.WORD rom_start
Basically I am on a Bender. As in the robot kind. From Futurama. I am building a full sized Bender robot with a beer brewing barrel inside him. That was simple enough but never being content with nice, easy projects I decided it would be cool to make him talk. I decided it would be even cooler and in keeping with a joke on the show if Benders 'brain' was 6502 based.
I have built a small circuit which is basically a binary counter hooked into some ROM chips programmed with audio samples. I am using 27c2001/27c020s. The counter counts up through the ROMs address lines clocking out the data which is then fed into a latch and finally a 8 bit R2R D to A. All very crude but actually fairly effective. I built the circuit such that I can test it seperately with a 555 providing clock pulses. This works now and I can play audio from the chip.
The next step is making all this micro controlled. I could make a 6502 SBC from scratch to drive it but as I have a 1541 disk drive here (that someone gave me over 10 years ago) I decided to hack that instead to see if the idea will work. What I have done is make an adaptor that plugs in where the 6522 VIA that controls the drive mechanism goes (UC2 which is at 1C00h). This adaptor allows through all the pins except all the port A and B pins and the CA1/2 CB1/2 pins. Those are then broken out and wired through to my circuit.
My idea is to reprogram the 1541 ROM and control the VIA to drive my circuit. I use the VIAs onboard timer to generate the clock signal I need to clock my audio circuit (at 16khz). I use 4 bits on one of the ports to drive the top four address bits of each of my memory chips. Using 4 bits this way means I can access the audio in one second blocks. I use the other four bits to do chip selection of each of my audio ROM chips. Clocking audio at at 16kHz allows me 16 seconds of audio per chip and I can have up to 10 chips (using a 1 into 10 decoder for the chip select).
I was going to get clever and have lookup tables in the audio chips so I could read them to see what samples there were and where but as the audio ROM isn't hooked to the data bus (only the latch) I decided against that. I will just hardcode the starting addresses of the samples into the controlling program. Once I get the thing working I can't see wanting to change the samples anyway.
I am currently trying to get a simple program running on the hacked drive board just to get my head around 6502 programming and to see if I can setp the VIA how I need it. I am using 27c64 ROMS in place of the drives 2364 using a pin adaptor. There may be something odd about these ROMS. They are a Fujitsu part and need a 21v programming level. They might be a 6 volt part and that may be causing my problems. I did also use one of the 27c2001s though (ignoring the upper address pins) as a test and get the same results.
Basically I have written a little program that should simply loop around setting and resetting the VIA port pins. I have a small handheld scope that is good enough to show me pins wiggling up and down (but not much more). What seems to be happening is my code is running I think. I can see the address lines on the ROM changing and also see the data being switched out. I have no way to telling what the data is of course, just that it is there. When I look at the 1-10 chip select on the 1541 though it isn't selecting the VIA at all. Only the output for number 1 is changing. I expect to see the CS2 chip select pins on the VIA toggling but I don't.
I am new to 6502 coding although I have played with PICs in the past (in fact I have made the same circuit before using a PIC as the controller and that worked fine). I am using the Kowalski 6502 simulator/assembler to write and test the code. In the simulator it works fine. I can see the memory at 1C00h and 1C01h toggle.
If I am understanding the 1541 circuit and disassembly correctly the ROM chip I am replacing is at address E000h to FFFFh. This is UB4 on the board (closest to the heatsink). The VIA is UC2 and at address 1C00h.
I am not sure of my code so I have included it here. Once assembled I save it as a binary take the hex code and open it in Visual Studio. I remove all the blanks at the start (0000h to DFFFh) so the code starts at 0000h and the reset vector is at 1FFCh and I program this into my ROM chip. Once on the board everything should then match up fine (code starting at E000h and reset at FFFCh).
I can't understand why I am not seeing the VIA chip being selected. If the addresses are clocking through OK as they do on the simulator then the VIA ports should be alternating 1 and 0s. I am sure I have missed something blindingly obvious or am doing something silly which is why it isn't working. I just need someone to slap me on the head and point it out!
I may in the mean time start building a new board from scratch and just use the chips off the 1541 in that. Be a lot neater and smaller but using the 1541 is a good test for now.
Simon
Here is the code (formatting probably messed up posting it here):
rom_start = $E000
reset = $Fffc
via = $1c00
via_b = via + 0
via_a = via + 1
via_bdir = via + 2
via_adir = via + 3
.ORG rom_start
LDA #$FF ; Load acc with FFh
STA via_bdir ; Set port b all output
STA via_adir ; Set port a all output
loop
LDA #$AA ; Data
STA via_b ; Load data on port b
STA via_a ; Load data on port a
LDA #$55 ; Data
STA via_b ; Load data on port b
STA via_a ; Load data on port a
JMP loop
.ORG reset ; Reset vector
.WORD rom_start