We have communication... Sort of.

I probably should have worried when my friend Arrow said that when he learned about RS-232 in school (he's an electrical engineer), that it hurt his head and he immediately forgot it after he was done needing it. But the internet makes it seem like such an easy concept. I mean, once you get past the fact that it really isn't RS-232, and it's by only the loosest of definitions a standard, more like a collective suggestion of rules that have so many caveats that it hurts your head.

I really thought this was going to be a straightforward video this week. I'd connect all the wires and start writing code. And I did that. Then nothing happened. This isn't my best video editing, as I missed some things I should have captured, and captured a lot of time that I didn't really end up using. Needless to say, the frustration of the project was spilling over into the documenting of it.

But it was very educational. And I'd be happy to answer questions about what happened.

https://youtu.be/9rt_dzmYkqE

What went wrong?

  • Trying to overcomplicate the line driver setup.
  • Trying to use all the pins.
  • Not understanding how a timing crystal works.
  • Making a mistake on my PCB design

First and foremost, I probably should have looked at more existing diagrams and projects before I started, though I spent a ton of time doing that, I missed some kind of obvious things until I actually started building. But I chock that up to not knowing what questions to ask until I hit a roadblock.
Namely the MAX232 Line Driver. I could use two and run every pin, well 8 of the 9, since Ring Indicator won't be necessary.

I ended up looking up the MAX232 Development Board schematics, and seeing that only RX/TX, and RTS/CTS are used and driven by a single chip, I redesigned my board, and tied the other lines to ground so they don't hold up the ACIA.

I got very hung up trying to figure out why I wasn't sending any data at this point. The code was right, the wiring and decode logic was right, but the 6551 would not send data to the serial port. Out came my oscilloscope for the first time!

Hantek 6022be Oscilloscope - USB

I connected to the serial port TX line to see what was going out...
NOTHING.

I connected to the serial port RX line to see if it was receiving (maybe it was on the other end that was a problem?
RECEIVING.

I started probing every junction all the way back to the 6551, and I could receive but not send, over and over.
I checked the setup code.
I checked the setup code again.
I slowed down the clock and watched it pick the right registers with LEDs.

After two nights of this, I finally checked the oscillator to see if it was just running at a weird speed...
It was not generating ANY signal.

WTF.

I looked at the different diagrams. I looked at other people's diagrams. I looked at every datasheet. Apparently, it's just well known that you have to connect the crystal not just between the two pins, but also to +5V somehow, to get it to actually resonate and make a clock signal. 😡
So I added two 22pf capacitors, one to each end, as I saw on an adafruit kit, and all of a sudden I have a 1.8432 MHz signal!

I had written code to send all the ASCII characters from 0x20 to 0x7F, which is all the visible characters (plus backspace). And since I have the LCD interface wired in and working, I could compare what it was sending versus what the PC was receiving.
AND IT WASN'T A MATCH.
It was a partial match, though.

Finding an old problem

So apparently I somehow tied the pins for D4 and D5 together in my PCB. They then both connect to D5 on the data bus. So everything I was sending to the 6551 would get the bit for D5 in both places. This is obviously something I need to address going into the V3 board.

But because of this, my initial idea to run at 9600 baud, No Parity, 8 data bits, and 1 stop bit (9600,N,8,1), just wouldn't work. I would send data but PuTTY would just show me garbage characters. I figured between interference in the line from it being on breadboards and jumper wires, and the fact with bit 4 being stuck to bit 5, it was trying to use the external receiver clock (which it wasn't receiving) it was just getting confused. So I dropped the baud rate to 300 and it works. Just with sending and receiving the wrong characters sometimes.

Since one of the steps for the V3 board is to incorporate the 6551, I'll work on that. And I will be staying with the WDC W65C51, and just using the delay, rather than trying to source other 6551s that use the Transfer Buffer Empty flag. I'd rather have access to new stock than rely on NOS or pulled chips.

Wrapping up

It was a stressful week, with a lot of late nights trying to work on this. I hope the video showed this properly, and the next one should be a lot more fun. Well as much fun as PCB Design can be to watch. 😂

Previous
Previous

I won't spare you this rant...

Next
Next

I Made a Small Thing!