Looking for ideas on how to communicate with my 65c02...

Building your first 6502-based project? We'll help you get started here.
Post Reply
User avatar
cbmeeks
Posts: 1254
Joined: 17 Aug 2005
Location: Soddy-Daisy, TN USA
Contact:

Looking for ideas on how to communicate with my 65c02...

Post by cbmeeks »

This has been one of the reasons why I have delayed starting my 65c02 homebrew. I've always 'dreaded' the part where I have to mess with serial connections to/from my 65c02 and my Mac. I know it's probably easy for most of you.

Anyway, assuming I get started and connect the 65c02 to my Propeller (for ROM) and SRAM, I'm going to need to communicate with it.

I thought I would start with a small ROM that just blinked an LED to confirm the computer is working.

Then, I need to upload some type of BASIC or "OS" so that it understands the serial requests right?

So, what OS should I use?

And, on the hardware, are there any examples of adding a serial connection to the computer? I would like to use the serial port of the propeller if I could. And by serial port, I actually mean the USB port that is on my propeller dev board.

Any ideas on how to start this?

Thanks.
Cat; the other white meat.
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Looking for ideas on how to communicate with my 65c02...

Post by BigEd »

If the propeller sits on the 6502 bus, and is able to run or stall the 6502, then you should be able to intercept some chosen addresses, such that a read or write to these addresses is handled by the propeller as a read or respectively a write to its serial connection. You can get away without implementing a corresponding status register, but it would help a little to write one of those too: to see if there's an incoming byte to read, and to see if its ready to take the next outgoing byte. Beyond that, you might add interrupts, but you don't need to.

I think EhBASIC and also the early Microsoft Basics need only to be hooked up to a character input and character output routine: then you have a command line prompt and the ability to compute.
User avatar
Michael
Posts: 633
Joined: 13 Feb 2013
Location: Michigan, USA

Re: Looking for ideas on how to communicate with my 65c02...

Post by Michael »

Quote:
... are there any examples of adding a serial connection to the computer? I would like to use the serial port of the propeller if I could. And by serial port, I actually mean the USB port that is on my propeller dev board.
Have you looked at any of the work by Jac Goudsmit on his ProPeddle project? It may provide some good background information and insights...

Good luck on your project.

Cheerful regards, Mike
JenniferDigital
Posts: 92
Joined: 25 May 2015

Re: Looking for ideas on how to communicate with my 65c02...

Post by JenniferDigital »

I've a fun but slightly silly idea. Why don't you hook up a centronics (parallel port) printer for output then you can pretend it's one of those machines you see in flaky black and white. On the other hand, serial ports really aren't as scary as people think, just keep it minimal. TXD, RXD, CTS, RTS and ground. Set both ends the same and you're off to a good start.
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Looking for ideas on how to communicate with my 65c02...

Post by BigDumbDinosaur »

DigitalDunc wrote:
I've a fun but slightly silly idea. Why don't you hook up a centronics (parallel port) printer for output then you can pretend it's one of those machines you see in flaky black and white. On the other hand, serial ports really aren't as scary as people think, just keep it minimal. TXD, RXD, CTS, RTS and ground. Set both ends the same and you're off to a good start.
Excellent suggestion!

My POC unit talks to both the console and my UNIX software development machine via TIA-232, with both ports running at 115.2 Kbps. A TIA-232 plug-in card can be added to any PC that has a PCI, PCI-X or PCI-E slot. The idea of struggling to get a USB interface going to a hobby computer is ridiculous when proven and easily adapted interface technology like TIA-232 and Centronics (parallel) already exists.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
nyef
Posts: 235
Joined: 28 Jul 2013

Re: Looking for ideas on how to communicate with my 65c02...

Post by nyef »

BigDumbDinosaur wrote:
My POC unit talks to both the console and my UNIX software development machine via TIA-232, with both ports running at 115.2 Kbps. A TIA-232 plug-in card can be added to any PC that has a PCI, PCI-X or PCI-E slot. The idea of struggling to get a USB interface going to a hobby computer is ridiculous when proven and easily adapted interface technology like TIA-232 and Centronics (parallel) already exists.
Quite a few people have computers that don't have such expansion ports, though, just USB. For which, yes, USB->serial and go from there. I have yet to hear good things about any USB->Centronics adapter. And so it goes.

On my side, I just noticed within the past few minutes that the docking station for my main computer (a laptop) has a Male DB9 port on it... And it actually works, which is the really surprising part.
User avatar
Druzyek
Posts: 367
Joined: 12 May 2014
Contact:

Re: Looking for ideas on how to communicate with my 65c02...

Post by Druzyek »

I have used an FTDI cable to do USB->Serial conversion for 6 or 7 projects including one with a 6502 and another for an EEPROM programmer. It's very easy to get going.

http://www.ftdichip.com/Products/Cables ... Serial.htm

Actually, FTDI sells another chip (FT2232?) that can do USB->SPI. If you are afraid of serial, this would be even simpler than that. Get a 74HC595 or 74HC164 for output and a 74HC165 for input and you can transfer data between the PC and 6502.

http://www.ftdichip.com/Products/Cables/USBMPSSE.htm
unclouded
Posts: 81
Joined: 24 Feb 2015

Re: Looking for ideas on how to communicate with my 65c02...

Post by unclouded »

I use these to talk to my 6502 computer:

FTDI adapter

I especially like the arrows on the PCB showing which lines are driven by the adapter and which sensed, which helps me avoid contention, especially with RS-232. Does TX mean TX from the DTE ( computer / laptop) perspective or from DCE ( modem / peripheral device) perspective? I always have to double check.

And this is how I simulate a UART device on the 6502 bus:

UART_read() and UART_write()

This example is slightly complicated by the fact that the actual UART on my 6502 computer is provided by a second AVR which is accessed via SPI although that is transparent to the 6502.
User avatar
jac_goudsmit
Posts: 229
Joined: 23 Jun 2011
Location: Rancho Cucamonga, California
Contact:

Re: Looking for ideas on how to communicate with my 65c02...

Post by jac_goudsmit »

cbmeeks wrote:
This has been one of the reasons why I have delayed starting my 65c02 homebrew. I've always 'dreaded' the part where I have to mess with serial connections to/from my 65c02 and my Mac. I know it's probably easy for most of you.

Anyway, assuming I get started and connect the 65c02 to my Propeller (for ROM) and SRAM, I'm going to need to communicate with it.
My "L-Star" project is based on a Propeller bitbanging the 65C02. See https://hackaday.io/project/3620 and https://github.com/jacgoudsmit/l-star. It's based on a previous project called Propeddle that used more glue logic so the Propeller also had control over interrupts and whatnot. Propeddle is more advanced but L-Star is easier to understand. Feel free to use whatever you want from my Github repo (MIT license).

I found that a very easy way to let the 65C02 communicate with the outside world is to emulate the PIA of the Apple-1. Basically it takes up 4 addresses in 6502 address space, and the 6502 reads and writes data in a parallel way by storing a byte into, or reading a byte from a reserved address. The high bit of those bytes is used for flow control so only 7 bits of each byte are usable to transfer data, but 7 bits of data is enough for an ASCII terminal (*). The Propeller takes care of catching and providing the bytes in another cog, and converting them to/from the standard serial port that you also need for programming the Propeller. L-star also lets you use a (1-pin) video output and a PS/2 keyboard.
Quote:
I thought I would start with a small ROM that just blinked an LED to confirm the computer is working.
My first program when I started dabbling with Propellers bitbanging 6502's was to run a (text) video cog and sharing the video buffer with the 6502. I just hand-assembled a ROM that would increment a memory location in the video buffer, and looped forever. The result can be seen at https://www.youtube.com/watch?v=WBdACu4OK-s.
Quote:
Then, I need to upload some type of BASIC or "OS" so that it understands the serial requests right?
With an Apple-1 PIA emulator at address $D010, you can map the Woz monitor at $FF00 and some ram at $0000 and start playing. L-star's Apple-1 emulator maps an 8K ROM with Woz mon, Ken Wessen's Krusader and Apple Integer Basic into the top of 6502 address space, and there's enough memory left over to emulate about 16K of RAM. I played Star Trek (the BASIC program) on it :-)

I also made a setup that emulates the Ohio Scientific / OSI Superboard II (also known as the OSI Challenger C1P, also known as the UK101), but I still have to finish the ACIA emulator.
Quote:
So, what OS should I use?
It should be clear to you by now that it's very easy with current-day resources to bring up a simple 6502 system that has nothing other than a microcontroller to talk to the world. Basically most things you want to do have already been invented and can be easily obtained. Parts are cheap (you can even get a 512KB SRAM chip for a few dollars) and ROMs of old 6502 machines have been dumped and can be easily found on the Internet. A lot of Parallax enthusiasts have shared code such as serial port drivers and video drivers; all you need to do is write the "glue" firmware to let the 6502 access them. And if you run out of cogs, or memory, or pins, just add another Propeller!

I'm thinking in the future I would like to implement a hobby "bring-up system" that runs on the Propeller and lets you type 6502 assembly code which is then stored in a memory area that the 6502 thinks is ROM. This would possibly be a great way for beginners to get to know the 6502 and educate themselves on machine language, without spending a lot of money and time on EPROM burners and erasers and stuff like that.

I would also like to do something like a semi-graphic interface to emulate the KIM-1 or Elektor Junior 7-segment displays and keyboard on a video screen.

===Jac

(*) There are many ways to transfer digital information from the Propeller to the 6502. The most obvious one would be what I would call "simulated direct memory access": just let the Propeller load the binary data into a hub memory area somehow (maybe by emulating a floppy disk with the EEPROM or by transferring data via the serial port) and let the 6502 access it as part of its address area. It's up to you and you have total freedom of inventing "protocols" to transfer data between 6502 and Propeller.
User avatar
cbscpe
Posts: 491
Joined: 13 Oct 2013
Location: Switzerland
Contact:

Re: Looking for ideas on how to communicate with my 65c02...

Post by cbscpe »

Hi cbmeeks,

having a 65(C)02 talk to the Mac is easy. I suggest you use a 65(C)51 to start with because then you can use many of the monitor ROMs that have been published e.g. Daryl's http://sbc.rictor.org/sbcos.html. I normally use a modified original Apple (F8) ROM that instead using built-in video and keyboard uses the 65(C)51 as default IO device. To connect to the Mac I bought some of these http://www.mouser.ch/ProductDetail/FTDI ... dam%2fwe00. FTDI provides an official Mac OS X driver. I use SecureCRT to connect over the USB-to-Serial Adapter. Also a CMOS 6502 system draws so little power that I use the same adapter to provide 5V for the system. the USB-to-Serial Adpater has TTL levels and interfaces directly with RXD and TXD of the 65(C)51. It is a good idea to have a pull-up on RXD (1kOhm) near the 65(C)51 to avoid reflections that disturb the serial signal when running the 65C51 with 115kbaud. Just use the following code

Code: Select all

ACIA1portset	lda	#$10				; 115200baud/8/1
					sta	ACIA1ctl			; control reg 
instead of

Code: Select all

ACIA1portset   lda   #$1F               ; 19.2K/8/1
               sta   ACIA1ctl           ; control reg 
On the Mac I use 64tass as 6502 cross-assembler.

cheers

Peter
Post Reply