Page 1 of 1

Its been a while :)

Posted: Sun Mar 15, 2026 11:25 am
by deanflyer
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 :)

Re: Its been a while :)

Posted: Sun Mar 15, 2026 11:51 am
by BigDumbDinosaur
Welcome back!  The 6502 is kind of like an old girlfriend...she keeps popping up in your thoughts.  :D
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.  :mrgreen:  Me, I wouldn’t be so ambitious.  There’s a reason the good Lord invented UARTs.

Re: Its been a while :)

Posted: Sun Mar 15, 2026 6:24 pm
by barnacle
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.

Neil

Re: Its been a while :)

Posted: Wed Mar 18, 2026 8:23 am
by deanflyer
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.

Re: Its been a while :)

Posted: Thu Mar 19, 2026 2:49 am
by Michael
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.

Code: Select all

;******************************************************************
;                                                                 *
;   Filename: 12F683 Full-Duplex 9600 Demo.asm                    *
;     Author: Mike McLaren, K8LH                                  *
;       Date: 02-Jun-05  (last revision 04-Dec-05)                *
;                                                                 *
;    Full Duplex Bit-Banged 9600 Baud Serial I/O Demo             *
;                                                                 *
;   ·Uses 12F683 INTOSC running at 8-MHz                          *
;   ·Bit rate error 0.6% plus or minus 1.0% for INTOSC            *
;   ·Bit-banged 9600 baud serial I/O                              *
;     ·Full Duplex (TX and RX simultaneously)                     *
;     ·Interrupts at approximately 3X bit rate every              *
;      34.5 usecs (every 69 instruction cycles)                   *
;     ·Circular 16-byte RX character buffer                       *
;     ·Circular 16-byte TX character buffer                       *
;     ·Inverted TX and RX signals (MAX232A or similar             *
;      inverting RS-232 interface required)                       *
;   ·ISR and support routines Init232, Put232, and Get232         *
;    fit comfortably in the first 189 words of code space         *
;    occupying memory from 0x04 through 0xBC (185 words)          *
;                                                                 *
;      MPLab: 7.21    (tabs=8)                                    *
;      MPAsm: 4.02                                                *
;                                                                 *
;******************************************************************

Re: Its been a while :)

Posted: Thu Mar 19, 2026 7:45 am
by soci
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.

Re: Its been a while :)

Posted: Thu Mar 19, 2026 8:54 am
by drogon
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.

-Gordon

Re: Its been a while :)

Posted: Thu Mar 19, 2026 2:24 pm
by Michael
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.

Re: Its been a while :)

Posted: Thu Mar 19, 2026 5:06 pm
by BigEd
drogon wrote:
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.
Indeed - for links and info search this forum for UPURS.

Re: Its been a while :)

Posted: Fri Mar 20, 2026 10:24 am
by deanflyer
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.