So, during covid I had a lot of spare time and built a 6502 SBC. I got a my SBC up and running with a W65C02, W65C22, RAM and EEPROM and a GAL22V10 for the address logic and a 1602A LCD. It has since sat at home gathering dust. I think I'll ditch the 1602A as it looks nice but doesnt really do much.
I now finally have some spare time and the past couple of weeks I have been getting back up to speed again and I have written my own bit-banged 9600 baud half-duplex UART code which works flawlessly on the 6522 .
The next step is my own monitor and then implement a way of sending programs across the wire so I don't have to keep reflashing the EEPROM during coding/testing.
I also need to get back up to speed with Kicad (last version I used was V5 I think) and get my SBC PCB finished as I just spent 24 hours troubleshooting my code when it was actually a loose connection to CA1
Welcome back! The 6502 is kind of like an old girlfriend...she keeps popping up in your thoughts.
Quote:
I now finally have some spare time and the past couple of weeks I have been getting back up to speed again and I have written my own bit-banged 9600 baud half-duplex UART code which works flawlessly on the 6522 .
Now, let’s see that run full duplex. Me, I wouldn’t be so ambitious. There’s a reason the good Lord invented UARTs.
I've got full duplex UART code for AVR, but I think it runs more slowly, probably 4800. It clocks at 4* baud rate to find the start bit with some semblance of accuracy on an RX signal and uses the same clock to drive the TX engine. It was a long time ago.
At the moment the TX and RX is handled by 104 usec loops (1Mhz oscillator) just because!! Im busy writing an xmodem and a cli parser but I'll revisit the RX/TX code and put in the option to use the timer and shift register, with a bit of massaging I can probably get it to do 9600 full duplex.
I did buy a NXP UART ages ago but see they are now end of life so haven't touched it.
Main aim at the moment is to get xmodem running so I dont have to keep programming EEPROMs.
I wrote an interrupt driven full-duplex 9600 demo' for a little 8-pin PIC12F683 (8-MHz INTOSC) that made it onto PICLIST a long time ago. It used interrupts at 3x the bit rate and a relatively simple state machine and I recall the ISR code was nearly isochronous, using approximately 50% of overall processing bandwidth. Not sure what it would take to port something similar to 6502+6522.
I did one for the 12F675 (4 MHz) at 1200 baud. Does twice the interrupt rate in the duplex case with alternating intervals on the same timer. Unless rx/tx is close as then both are done in the same interrupt with a constant rate. Works nicely in simulator also at higher baud rates and faster controllers. In the real world it's in a keyboard converter (which also does ps/2 at the same time) so duplex operation only happens on initialization and led changes.
With a VIA I'd use separate timers for sure to avoid interval calculations.
I'm not convinced you need full duplex for a little project like this.
Or maybe I'm just justifying my own half-duplex minimal SBC... which runs at 38400 baud with the 6507 running from a 2Mhz xtal.
I can download code into it via my terminal program by making the receiving side not echo characters back during the transfer and allowing a short delay per character and a longer delay per line sent (Line of printable ASCII) It's not xmodem, but it doesn't need to be and since the most I can ever send to it is 3.5KB (It's only got 4KB of RAM) then that's a real limitation. It has the ability to re-program the EEPROM but I don't do that for the TinyBasic or Monitor, only for storing Basic programs.
There is a project over on stardot where someone has 115200 baud going into the 2Mhz 6502 too. That needs a very carefully timed loop.
I thought about trying half-duplex serial using a single VIA pin that switches between input and output as required. This method pretty much forces a hardware echo (like the KIM-1). I tried this on my version of Karen Orton's SCMP Emulator + NIBL BASIC and it worked well. As a bonus the diode prevented power back feeding the uC from the usb-serial adapter when the power switch on the board was switched off.
For what I'm using it for my current half-duplex 9600 code will suffice. It was code that I had started during covid, so just wanted to finish it now I have some more time.
115200 is impressive, that's 8.68 usec per pulse @2MHz.