6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 10:25 pm

All times are UTC




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Jan 24, 2024 3:51 pm 
Offline
User avatar

Joined: Tue Dec 12, 2023 7:00 pm
Posts: 25
Location: London, UK
I would appreciate if you could find some time to review my (rather simple) schematic and PCB design. This is my very first PCB, so you are more than welcome to roast me badly :D I definitely have more experience with ASM (and programming in general) than with the electronics, but the retro passion wouldn't be "complete" without dealing directly with the hardware, would it?

Project purpose
Mostly - debugging, secondly - learning. I am using Teensy 4.1 dev board to control W65C02 or W65C816 via serial port (or Ethernet) from my main computer. I do it mostly to test my emulator (written in Rust) against the actual CPU to guarantee cycle-level accuracy. The project is simple enough that perhaps designing a dedicated PCB (over breadboard-based solution, that I'm currently using) is an overkill, but - on the other hand - it's perfectly simple for learning purposes. Apart the Serial/Ethernet bridge, the PCB has 11 LEDs for quick status control (and a switch to disable them), a switch between 6502 and 65816 (that simpy either keeps 02's NC pin floating vs being connected). After designing all of that I've realised that I have enough Teensy pins available for one SPI connection, and seeing that my board had a size almost identical (now really identical) with ILI9341 3.2" LCD I decided to expand the capabilities of the project and there an option to have a screen at the back of the board. That, on top of debugging, would allow to use the board for some fun retro projects, similar to Olimex Neo 6502 (https://www.olimex.com/Products/Retro-Computers/Neo6502/open-source-hardware) with the advantage of the screen and much nicer (in my opinion) development board (Teensy) than RP2040 used by Olimex.

Files
All schematics, Gerber files and screenshots can be found in a browseable form on my Github: https://github.com/ddrcode/teensy_6502_ ... ee/pcb/pcb, but I have attached the main files here as well.

Design decisions (and questions)
1. 3.3V (for compatibility with Teensy and ILI9341)
2. The U3 and U4 ICs are simple line drivers (U4 is inverting one) to drive LEDs and to avoid powering the LEDs directly from signal lines. Curious whether you'd suggest other components for that job? Ideally I would prefer something in PDIP-14 (rather than 16) with all inputs on one side and outputs on the other (that would massively simplify my tracks), but - to my surprise - I couldn't find any. The closest with that layout (but in PDIP-16) I could find was TI 4000B series, but that means stepping into TTL theritory.
3. The dip switch controls the LED's "subcircuit" by simply cutting the VCC on/off. I could, theoretically, drive U3/U4 bus-enable signal instead, but then I'd need to deal with floating input to all LEDs and pull them down.
4. I decided to have all LEDs, resistors and capacitors in SMB form (all in 0805). I don't have bigger issues soldering 0805's and that's always a good practice of patience :-)
5. I use DS1818 to control reset function. I'm tempted to stabilize the pushbutton in the reset circuit with capacitor, but even the datasheet for DS1818 shows a circuit without any cap. Is that ok?
6. In two places on the PCB there are vias directly on solder pads (C4 and LED10). I know there are different opinions about placing vias on pads and I'm curious what's your (pragmatic) approach is?
7. Those tiny 0805 LEDs are super bright (I've tested S85CS5), especially having 11 of them. According to the math, I should be using 60-100 Ohm resistors for them, but in my actual tests, I had to increase the resistance up to 2-4k Ohms to use these LEDs as indicators rather than the source of light in my room :-)

If you have any questions, comments, suggestions - I'd love to hear from you. And thank you!

And, as it's one of my first posts here, I'd like to express my gratitude for this amazing Forum and the site. I spent my teenage years doing a lot of asm coding (on C16, C128 and then Amiga) and I find now a great pleasure being back to that world. In the world of blackboxes (called "AI"), dealing with something that can be fully understood and controlled, is extremely rewarding.


Attachments:
File comment: Schematic
teensy-bridge_2024-01-25-3.png
teensy-bridge_2024-01-25-3.png [ 249.19 KiB | Viewed 1780 times ]
File comment: PCB - bottom view
PCB_teensy-bridge-v1-bottom.png
PCB_teensy-bridge-v1-bottom.png [ 380.32 KiB | Viewed 2179 times ]
File comment: PCB - top view
PCB_teensy-bridge-v1-top.png
PCB_teensy-bridge-v1-top.png [ 493.43 KiB | Viewed 2179 times ]
File comment: 6502-Teensy Bridge - 3D model
PCB_teensy-bridge-v1-3d.png
PCB_teensy-bridge-v1-3d.png [ 472.54 KiB | Viewed 2179 times ]


Last edited by ytropek on Sun Jan 28, 2024 8:29 pm, edited 2 times in total.
Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 24, 2024 5:41 pm 
Offline
User avatar

Joined: Tue Feb 28, 2023 11:39 pm
Posts: 133
Location: Texas
Something I see is the use of the PHI2/PHI1 output pins from the WDC65C02S, those aren't really guaranteed to be accurate any longer according to the datasheets. If you want/need an inverse clock the way I like to do is is to put a 74xx74 off of an oscillator and use the Q/Q' to derive PHI2 and PHI1. (Or you could have the Teensy do it internally seeing as it looks like that's what you're using to generate your clock signal.)

Something of note, though not really critical, I have successfully put the ILI9341 right on the 6502's bus using the 8-bit interface. The board is doing a constant output though, so you'll need an extra line driver (e.g. 74HC245) to give you a floating state when the device isn't being accessed. (I can post a schematic if anyone is interested)

Another thread that might be relevant to your interests is the one on Single stepping with RDY


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 24, 2024 7:52 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8147
Location: Midwestern USA
ytropek wrote:
I would appreciate if you could find some time to review my (rather simple) schematic and PCB design.

I’m not able to read your schematic, but in examining the PCB layout I will mention that the 65C816 is not quite electrically interchangeable with the 65C02.  Best if you go over the pinouts on the respective data sheets and note the differences.  Some jumpers can be used to make the board work with either MPU.

Also, the bus cycle with the 65C816 is different than that of the 65C02 during Ø2 low.  Your chip select logic may need to reflect this.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 24, 2024 8:47 pm 
Offline
User avatar

Joined: Tue Dec 12, 2023 7:00 pm
Posts: 25
Location: London, UK
Thank you for your comments, Yuri

Yuri wrote:
Something I see is the use of the PHI2/PHI1 output pins from the WDC65C02S, those aren't really guaranteed to be accurate any longer according to the datasheets. If you want/need an inverse clock the way I like to do is is to put a 74xx74 off of an oscillator and use the Q/Q' to derive PHI2 and PHI1.

I'm aware the phi-out signals are slightly shorter than the actual Phi0. I'm not planning to use them for my personal project. However the idea of this board is to make it a tool for monitoring all MPU inputs and outputs, so if any potential user will find a need to monitor these two pins (or, more likely, VDA and Abort pins on '816) - there is an option.

Yuri wrote:
Something of note, though not really critical, I have successfully put the ILI9341 right on the 6502's bus using the 8-bit interface. The board is doing a constant output though, so you'll need an extra line driver (e.g. 74HC245) to give you a floating state when the device isn't being accessed. (I can post a schematic if anyone is interested)

I am very interested! Of course in the project described here the screen is driven by Teensy, but I've been thinking about driving ILI9341 without any microcontroller, and - similarly to you - I thought the 8-bit interface is the way to go. Would be happy to see your solution. Btw - 74HC245 looks like interesting IC, even for this project, but I couldn't find any 3.3V version, at least in DIP package.

Yuri wrote:
Another thread that might be relevant to your interests is the one on Single stepping with RDY

Yes, I remember that thread. Although, with WDC MPUs being static, debugging by controlling the clock by microcontroller seems to me a simpler solution and giving slightly more control. Rady pin makes lots of sense when debugging with WAI.


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 24, 2024 8:57 pm 
Offline
User avatar

Joined: Tue Dec 12, 2023 7:00 pm
Posts: 25
Location: London, UK
BigDumbDinosaur wrote:
I’m not able to read your schematic, but in examining the PCB layout I will mention that the 65C816 is not quite electrically interchangeable with the 65C02.  Best if you go over the pinouts on the respective data sheets and note the differences.  Some jumpers can be used to make the board work with either MPU.
Also, the bus cycle with the 65C816 is different than that of the 65C02 during Ø2 low.  Your chip select logic may need to reflect this.[/color]

Thank you for your comment. I've been using both MPUs, so I'm aware about the differences between some pins, but - correct me if I am wrong, please - as I control the MPU completely from the MC, the differences can be handled on the configuration/software level, rather than "physical" (PCB). The same applies to bus cycle. The only physical difference I can think of is pin 35 (NC on '02 and M on '816) - and that is handled on my board with a DIP switch. Other differences, like Abort, VPA, VDD, VDA and MX can be handled from the software running on Teensy. Or do I miss something?


Top
 Profile  
Reply with quote  
PostPosted: Wed Jan 24, 2024 11:12 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8147
Location: Midwestern USA
ytropek wrote:
The only physical difference I can think of is pin 35 (NC on '02 and M on '816) - and that is handled on my board with a DIP switch.

In the DIP packages, pin 3 on the 65C02 is PHI1O—an output, but is ABORT on the 65C816—an input that must be driven high if unused.  Additionally, pin 7 on the C02 is SYNC, but is VPA on the 816.  Depending on how your glue logic is arranged, you may need VPA to qualify opcode and operand fetch cycles.

Quote:
Other differences, like Abort, VPA, VDD, VDA and MX can be handled from the software running on Teensy. Or do I miss something?

As I said above, I can’t read your schematic, so I’m not able to offer much advice on the electrical end of things.  Handling signals such as ABORT, VDA, etc., is a circuit design aspect, not something that you would do in software.  In particular, use of VDA and VPA may be necessary to avoid aberrant behavior during the so-called dead bus cycles.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 25, 2024 1:03 pm 
Offline
User avatar

Joined: Tue Dec 12, 2023 7:00 pm
Posts: 25
Location: London, UK
BigDumbDinosaur wrote:
I can’t read your schematic, so I’m not able to offer much advice on the electrical end of things

What's actually the issue with the schematic - it doesn't open for you, or is too small and not readable? Could you try this link instead?

BigDumbDinosaur wrote:
In the DIP packages, pin 3 on the 65C02 is PHI1O—an output, but is ABORT on the 65C816—an input that must be driven high if unused.  Additionally, pin 7 on the C02 is SYNC, but is VPA on the 816.  Depending on how your glue logic is arranged, you may need VPA to qualify opcode and operand fetch cycles.

I think we have two different things in mind. Your comments would make, naturally, a lot of sense if my board was a computer. But it isn't - it doesn't have ROM, RAM or even a bus. It's just 40 CPU pins connected to 40 pins of Teensy. Think about a 100% emulated computer, and then a variation of it, where everything apart CPU is emulated - this is the case here. As mentioned in the first post in the thread, I've designed this board mainly for debugging purposes. I implemented an emulator, and to be sure that it's cycle-accurate with a real hardware, I want to run it in parallel with the actual CPU and compare, for every cycle, the state of all inputs and outputs. Means everything besides CPU is emulated - the memory, the bus, I/O. The emulation doesn't even run on Teensy, but on my host computer. This is why a call the project a "Bridge" as Teensy only acts the role of connecting my main machine with the processor via serial or Ethernet (you can find the implementation of that bridge on my Github if you're interested). In such approach I have full control over all processor inputs, and can - programmatically - respond to all outputs. So handling cases like VDA and VPA being low is not a problem. I don't think the board itself needs to have anything specific for that case, even a DIP switch for switching me between '02 and '816. It's just a matter of using a dedicated software/configuration for one processor or another. If I am wrong, I'd need to understand why...

As mentioned above, I made an exception (a DIP switch) for pin 35. The datasheet for W65C02 states it should be kept unconnected, while on W65C816 it's an emulation pin (M). So the switch actually either connects the pin with my Teensy or keeps the pin floating. There were some debates on this Forum that keeping that pin pulled low (or high) should be absolutely safe, but I decided to take this approach. For all other pins I decide on software level whether they are inputs or outputs and what's their meaning. Hope that makes sense.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 25, 2024 1:19 pm 
Offline
User avatar

Joined: Fri Aug 03, 2018 8:52 am
Posts: 745
Location: Germany
The issue is probably the color. Just export it as a black&white PDF and it should be fine. Though BDD could've specified that himself :p


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 25, 2024 2:27 pm 
Offline
User avatar

Joined: Tue Dec 12, 2023 7:00 pm
Posts: 25
Location: London, UK
Proxy wrote:
The issue is probably the color. Just export it as a black&white PDF and it should be fine. Though BDD could've specified that himself :p


Couldn't change the colour on export, but here is the pdf with vector graphics, so at least can be scaled properly...

[edit] I've actually managed to convert it to B&W


Attachments:
teensy-bridge_2024-01-25-3.pdf [35.52 KiB]
Downloaded 23 times


Last edited by ytropek on Sun Jan 28, 2024 8:31 pm, edited 1 time in total.
Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 25, 2024 2:30 pm 
Offline

Joined: Tue Sep 03, 2002 12:58 pm
Posts: 293
Some points that haven't been addressed:

I assume the wiggles in many of the tracks are to keep their lengths equal. That's not necessary. The difference in length will be an insignificant fraction of the clock period. The only place I'd keep the wiggles is on the differential pairs to the ethernet connector (it might not be necessary there either, but I don't have sufficient experience with ethernet to know for sure).

You're turning the LEDs off by disconnecting the 368's power. That will end up with it, and the LEDs being powered by any of the inputs that happen to be high, through the protection diodes. It won't reliably turn the LEDs off and might damage the chip. Output enable is the method to use here. The LEDs don't care if their anodes are floating - they're not like CMOS inputs.


Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 25, 2024 2:48 pm 
Offline
User avatar

Joined: Tue Dec 12, 2023 7:00 pm
Posts: 25
Location: London, UK
John West wrote:
I assume the wiggles in many of the tracks are to keep their lengths equal. That's not necessary. The difference in length will be an insignificant fraction of the clock period. The only place I'd keep the wiggles is on the differential pairs to the ethernet connector (it might not be necessary there either, but I don't have sufficient experience with ethernet to know for sure).

Yes I wanted to equal the length of the tracks, et least the important ones. Thanks a lot for your remarks.

John West wrote:
You're turning the LEDs off by disconnecting the 368's power. That will end up with it, and the LEDs being powered by any of the inputs that happen to be high, through the protection diodes. It won't reliably turn the LEDs off and might damage the chip. Output enable is the method to use here. The LEDs don't care if their anodes are floating - they're not like CMOS inputs.

Thanks a lot for that comment - makes a lot of sense. Funny enough that was my original design (with output enable), so a little bit of work to redo now on PCB :-) I've attached an updated schematic - DIP switch driving OE# and a pullup resistor.


Attachments:
teensy-bridge_2024-01-25.pdf [138.23 KiB]
Downloaded 24 times
Top
 Profile  
Reply with quote  
PostPosted: Thu Jan 25, 2024 6:27 pm 
Offline
User avatar

Joined: Tue Feb 28, 2023 11:39 pm
Posts: 133
Location: Texas
ytropek wrote:
Yuri wrote:
Something of note, though not really critical, I have successfully put the ILI9341 right on the 6502's bus using the 8-bit interface. The board is doing a constant output though, so you'll need an extra line driver (e.g. 74HC245) to give you a floating state when the device isn't being accessed. (I can post a schematic if anyone is interested)

I am very interested! Of course in the project described here the screen is driven by Teensy, but I've been thinking about driving ILI9341 without any microcontroller, and - similarly to you - I thought the 8-bit interface is the way to go. Would be happy to see your solution. Btw - 74HC245 looks like interesting IC, even for this project, but I couldn't find any 3.3V version, at least in DIP package.


This is a rough approximation of what I'm doing in my circuit (converted to use 3.3V parts)

You don't need to do the address decoding the way I am, that's just how I'm currently doing it on my breadboard setup.

In my tests the board did not float the bus when chip select was disabled, so I had to add the '245 to do that.

Otherwise it's just as simple as writing to the addresses that it is mapped to.
There are two addresses it responds to. $XX00 for the command register and $XX01 for the data register.

I've been taking the AdaFruit Arduino library for this display and using that as a basis to do my 6502 version of the library.
Attached the code files that show identifying the display, initializing it, and drawing a single pixel.

Hope you find this useful!


Attachments:
dispcmds.s [939 Bytes]
Downloaded 22 times
display.s [3.32 KiB]
Downloaded 24 times
imi9341.pdf [260.96 KiB]
Downloaded 28 times
Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 28, 2024 7:45 pm 
Offline
User avatar

Joined: Tue Dec 12, 2023 7:00 pm
Posts: 25
Location: London, UK
Hi Yuri

Thank you so much for sharing this - I really like your example and very clean CA65 code. Do you have it already fully working - beyond the single pixel test? I would be glad to see some photos of your computer
with the ILI screen. I like the designs with digital video outputs.

Yuri wrote:
You don't need to do the address decoding the way I am, that's just how I'm currently doing it on my breadboard setup.
In my tests the board did not float the bus when chip select was disabled, so I had to add the '245 to do that.


Of course I looked at the schematic first, before reading the post, so I was bit confused initially. ;-)

Yuri wrote:
Hope you find this useful!

Very useful, thank you so much. You've encouraged me to do the same for '816. Will let you know!


Top
 Profile  
Reply with quote  
PostPosted: Sun Jan 28, 2024 8:26 pm 
Offline
User avatar

Joined: Tue Dec 12, 2023 7:00 pm
Posts: 25
Location: London, UK
Proxy wrote:
The issue is probably the color. Just export it as a black&white PDF and it should be fine.


B&W version attached


Attachments:
File comment: Schematic in B&W
teensy-bridge_2024-01-25-3.pdf [35.52 KiB]
Downloaded 23 times
Top
 Profile  
Reply with quote  
PostPosted: Mon Jan 29, 2024 12:15 am 
Offline
User avatar

Joined: Fri Jan 26, 2024 5:47 am
Posts: 37
Location: Prague; Czech Republic; Europe; Earth
Hello, I just joined in :)

Here are some my thoughts:

2) I would use '245 probabely, it is 20 pins, but drives all 8 bits. As for inverting, I would connect those LEDs again Vcc or GND, as wil be needed.
(I also made combo Vcc-LED-resistor-pin-resistor-LED-ground, which undriven is weak glow of both LED, driven it is bright glow of one, or other LED and on PWM it is bright both LEDs and successfuly use it in Expanduino)
3) I would use the enable/disable line. I many times use LED-resistor not only as indicator, but also as puill-up or pull-down. For just indicating I separate the LEDs by transistors or by any IC used for output (NAND, NOR with joined inputs to make NOT driver or so)
6) I will be not afraid of that, but I lack theory here. Anyway I soldered some circuits on universal board (proto board?) which is just lot of vias, spaced 0.1 inch and nothing more - and it worked nice :twisted:
7) I am using 1k resistors on 5V for LED indicators and it is not dim. I used 330 Ohms, but then I could not see the wires around :lol:

About the NC pin - AVR/ATMEGA/Arduino boots with all pins in INPUT state - that means high rezistance - so if you connect it to Arduino and leave it such for 65C02, it should be OK, as there would be effectively connected just the short wire. And for '816 you can drive it yourself. But I would add a jumper, just to set, which CPU is inserted, so Teensy could read it after boot and set everything acordingly.

For Black&White in KiCad is easy to make B&W scheme ( (Preferencies / Preferencies (Ctrl+,) / Schematic Editor / Colors - click Theme and select Black & White, OK - or select New Theme and customize it) You can then use the theme only for printing, or switch it with default on your will. (On my computer it was saved into /home/gilhad/.config/kicad/7.0/colors directory, on yours it should be something similar)

_________________
http://micro-corner.gilhad.cz/, http://8bit.gilhad.cz/6809/Expanduino/Expanduino_I.html, http://comp24.gilhad.cz/Comp24-specification.html, and many others


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 22 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: