6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 4:37 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Mon Jul 20, 2015 7:46 pm 
Offline

Joined: Mon Jul 20, 2015 6:34 pm
Posts: 62
First of all, this is my first post. This forum was a valuable asset to me while I did my project. A special thanks to Garth Wilson for his 6502 primer. It was invaluable.

I'm trying to make a prototype for my 6502 project, a psid player.

Here you can see in action,

https://www.youtube.com/watch?v=MBIUJIpaeXw

Since I lack the skills in the pcb design compartment I decided to build the prototype apartment style making everything adapt to 6502's 40 pin interface.

My cpu board contains,

- 1 mhz oscillator
- 32kx2 SRAM
- 27C512 EPROM (I only need 1 page of read only memory actually but couldn't find smaller eprom, will be replaced by eeprom)
- Address decoder with bunch of 74 series chips.

And I have a controlling Mcu, it was previously a 8 bit pic. Now it's an arduino uno. It drives the display & sd card and boots 6502 filling required program into it using S.O. / IRQ and NMI pins. Currently it can fill the memory asynchronously 1.5k per second or so, with optimizations it's possible to increase this to 4-5k or so. Arduino is not connected to databus or address bus hence the read only memory requirement.

Boards I've build could be seen in the attached picture. Of course it didn't work in the first time. So I started testing each layer individually. Cpu board tested ok and passed the NOP test. Eprom fitted and it seems to be working ok too. Now to test the sram I thought it would be nice attach a simple circuit to the existing lot so that I can transfer data to arduino. I have a VIA but at this stage of building the circuit it wouldn't be wise to build something around it and introduce more issues. Instead I thought I could fit a 74165 (74HC165 in my case) parallel input serial output shift register as a memory mapped I/O device.

The idea is, decode address for 74165 in a certain memory range. The byte to be sent is addressed as say,

Code:
LDA BYTETOSEND
STA DECODEDADDRESS
; Idle loop enough for arduino to do it's job (serially read data)


Chip select signal for the decoding is tied to the LATCH/ input, data bus is tied to the 8 parallel inputs of the 74165. 6502 code waits a bit after addressing the decoded address so arduino can fetch the data serially. Arduino drives the CLOCK input of 74165 by the way and retrieves data through serial output of 74165 and sends this data serially to the pc. (same CS signal for 74165 is also used as an interrupt signal for arduino )

To keep it simple I now decode full 0-7FFF range to 74165 using NOT A15. Decoding ROM as A15. Accessing the 74165 at $1000. Getting it run I can trace individual bytes indeed sent to the arduino side but they all come as $FFs. (Edit, it's other way around actually... A15 -> 74165, NOT A15 -> ROM. Don't know how to strikethrough written text. )

Well the question is,

1. Feasibility aside, could 74165 indeed be interfaced to 6502 in this fashion?
2. What do you think is wrong with my setup?

I tested these too,

1. Using PHI2 NAND (NOT A15) to decode 74165. This somewhat produces a 1mhz square wave even though my program only accesses $1000 address 11 times and everything else is between $FF00 and $FFFF.
2. I tried to feed low A0-A7 bits into the 74165. I changed the code so that whatever I want to send is addressed between $1000 and $10FF. Still got all $FFs.

ps1: I don't have filtering caps on the VCC line of each IC in this prototype. I know I should add them as soon as possible.
ps2: I fitted SRAMs one on the top of other. Either I'll upgrade in this prototype setup to more capacity sram or place them side by side since they take vertical space and not very usable currently. And I must admit, using sockets for ICs in this setup is not a good idea too. They also take vertical space.


Attachments:
20150716_022516.jpg
20150716_022516.jpg [ 94.14 KiB | Viewed 1205 times ]


Last edited by i_r_on on Mon Jul 20, 2015 10:04 pm, edited 1 time in total.
Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 20, 2015 9:40 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
i_r_on wrote:
First of all, this is my first post. This forum was a valuable asset to me while I did my project. A special thanks to Garth Wilson for his 6502 primer. It was invaluable.

Welcome, and you're welcome!

Quote:
Getting it run I can trace individual bytes indeed sent to the arduino side but they all come as $FFs.

Well the question is,

1. Feasibility aside, could 74165 indeed be interfaced to 6502 in this fashion?
2. What do you think is wrong with my setup?

I have a similar circuit for the '165 at http://wilsonminesco.com/6502primer/pot ... l#22_SR_IN although that one is to bring data in, not sent it out. You don't show your circuit, but make sure you have the clock inhibit (pin 15) tied low.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 20, 2015 10:23 pm 
Offline

Joined: Mon Jul 20, 2015 6:34 pm
Posts: 62
GARTHWILSON wrote:
Welcome, and you're welcome!

Thanks :)

GARTHWILSON wrote:
I have a similar circuit for the '165 at http://wilsonminesco.com/6502primer/pot ... l#22_SR_IN although that one is to bring data in, not sent it out. You don't show your circuit, but make sure you have the clock inhibit (pin 15) tied low.


Well I did tie it to ground actually. Previously I did a 16 and 24 button usb controller with '165 ICS and Arduino pro micro so I'm a bit familiar with them. I don't have a circuit handy but connections are like this.

GND -> '165:CLK INH
D0..D7 or A0..A7 -> '165:[A..H]
'165:QH -> Arduino digital input (here data read serially)
A15 -> '165:[LD/]
A15 -> Arduino Interrupt Input (Falling edge)
Clock signal from Arduino -> '165:CLOCK

74HC04 is used for Eprom's chip select signal (NOT A15)


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 21, 2015 11:19 pm 
Offline

Joined: Mon Jul 20, 2015 6:34 pm
Posts: 62
For simple, crude debugging purposes for this prototyping I changed the approach to a less timing critical one btw.

I wired a 74138 3 to 8 decoder to select inputs from A15, A14 and A13...
Which decodes
- $E000-FFFF as rom (output Q7)
- $8000-9FFF as interrupt signal 0 to arduino (output Q4)
- $A000-BFFF as interrupt signal 1 to arduino (output Q5)

On 6502 side on rom code I take a byte and bit shift it by using 8 ROLs and simply access $8000 if carry is zero or access $A000 if it is 1. Believe it or not, 16mhz arduino needs a lot of delay on 6502 side to handle interrupts produced by 74138's outputs. After a little bit of fiddling I was able to work it out. Needs a bit of tweaking for the start of transfer since I get an excess 0 at the start of the transfer which I can possibly solve sending a bit stream that is a starting marker. Actually that's not even needed at all since transferred data is meaningful backwards and it's only meant to be manually controlled. I need a more elegant testing approach if I produce the actual pcbs anyway.

Speed is not important since I'll just use this to check if added ram is indeed accessible, if stack works as expected, if my transfer routine to the 6502 side working as expected and so on. Just to test the prototype boards.

Here is the code I use to make it more clear... (Btw I'm still curious as to why 74165 trick didn't work as I expected.)

Code:
HELLO   .DB "HELLO WORLD"
   LDX #$00
   
NEXT:
   LDA HELLO, X   
   LDY #$08   
SINGLEBITSEND:   
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP
   NOP      
   ROL
   BCS ONE
   STA $8000   
   JMP NEXTBIT   
ONE:   
   STA $A000
NEXTBIT:
   DEY
   BNE SINGLEBITSEND
   INX
   CPX #11
   BNE NEXT   


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 52 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: