Українською
  In English
Reddit:Electronics

Achievement unlocked! My Homebrew CPU now has a working serial interface!
I'm back again! I've posted here a few times about my project:
- 4 years ago: video card bringup
- 3 years ago: basic CPU operation with program counter, insruction sequencing, and RAM store/load operations
- 2 years ago: Complete CPU operations including ALU and stack
- 7 months ago: Keyboard and Timer interfaces complete
And now...the final piece is done...the serial interface is working!
I used an 8086-era 82C52 UART instead of the more common 8250 or 16550, because those are such huge chips that I would have run out of space on my prototyping board. Also, while the 16-byte buffers on the more common modern UARTs are nice, my CPU runs at 2+MHz and supports interrupts, and so it's not hard at all to keep the 1-byte transmit and receive buffers clear.
The 82C52 UART is wired up to a MAX202 RS232 interface chip (it's functionally identical to a MAX232 but uses smaller capacitors for the charge pumps). I have it wired up in "5 wire" serial mode, with RxD, TxD, CTS, RTS, and GND plumbed to the DB9. I could add another MAX202 and connect 4 more signals (DSR, DTD, RTR, DTR) but those are really not needed unless I'm trying to hook my system up to some old modem or teletype that expects them. Even CTS and RTS aren't technically required, but since I had enough ports on the MAX202 I went ahead and wired them up so I could do CTS/RTS hardware flow control.
The 82C52 is able to generate three kinds of interrupts, but I only use two of them -- a generic INTR signal that can be used to do things like detect breaks or parity errors, and the DR interrupt that tells the CPU a byte has been received. There is also a TBRE interrupt that tells the CPU that the transmit buffer is empty, but I don't have that one wired up, as I can obtain the same information by simply polling the UART status register after transmitting a byte. If I end up needing to transmit data from the CPU at a high data rate while also doing other processing in the background (which is unlikely) then I may eventually wire TBRE up to a free interrupt line.
I am using a 10.000MHz crystal to drive the 82C52's baud rate generator, which isn't ideal (most baud rates come in at around 1.3%-1.7% error) but I tested all the way from 1200 to 115200 baud, and it seems to work fine even when receiving a constant stream of data from my laptop.
Here's a video showing the serial interface in action: https://photos.app.goo.gl/iAW7D1CkQjY4A28P6
This was the final module I wanted to build for my Homebrew CPU -- so now I move on to "polishing" work. I need to build (or maybe 3D print) a proper enclosure for everything. And now it's time to focus on the software -- I need to write an OS/shell type thing so that it boots into something interactive that lets me load and run programs (over serial, or stored in ROM). I also need to get some documentation put together explaining how the whole system works, along with the pros/cons of the architecture I came up with.
At some point in the future I might add a 32K RAM expansion (I have an 8K hole in the address space I could use to create a "windowed" expanded RAM), and a persistent storage system (perhaps an SD card, or heck, maybe I'll make a cassette interface and be super retro :-)
Still a lot more to do! A big thanks to all the /r/electronics folks that have helped along the way.
[link] [comments]
Lemmy Electronics
![]() | submitted by /u/1Davide [link] [comments] |
Weekly discussion, complaint, and rant thread
Open to anything, including discussions, complaints, and rants.
Sub rules do not apply, so don't bother reporting incivility, off-topic, or spam.
Reddit-wide rules do apply.
To see the newest posts, sort the comments by "new" (instead of "best" or "top").
[link] [comments]