Page 1 of 1
6502 bit-banged serial code examples?
Posted: Mon May 17, 2021 9:06 pm
by Michael
as the title suggests, can anyone point me to code examples for bit-banged serial, please? I'd like to use a 6522 but the hardware doesn't matter that much.
tia. cheerful regards, Mike, K8LH
Re: 6502 bit-banged serial code examples?
Posted: Mon May 17, 2021 9:25 pm
by GARTHWILSON
For synchronous serial, I have sample code for SPI at http://wilsonminesco.com/6502primer/SPI.ASM, and for I²C in various forms at http://wilsonminesco.com/6502primer/GENRLI2C.ASM . For asynchronous (mostly meaning RS-232, but it could also be RS-422 or RS-485 with the right line drivers and receivers), someone posted code here on the forum for doing 56kbps on a 1MHz 6502 IIRC.
Re: 6502 bit-banged serial code examples?
Posted: Mon May 17, 2021 9:48 pm
by jds
If you could find a listing of the TIM monitor ROM I’m pretty sure that it uses bit-banged serial on the 6532. The monitor listing is in the TIM manual and should be easy to find.
Re: 6502 bit-banged serial code examples?
Posted: Tue May 18, 2021 4:48 am
by Dr Jefyll
I posted some SPI routines for 6522
here. There're also some suggestions regarding which port bits to use for what. The priority is speed, and the routines require less than 20 clocks per SPI bit.
-- Jeff
Re: 6502 bit-banged serial code examples?
Posted: Tue May 18, 2021 7:20 am
by BigEd
A previous thread cooks up a serial driver, and also
links to MartinB's implementation (UPURS) as seen on stardot:
Edit: and a couple of our mos6502 weekly posts too, indexed
here:
Re: 6502 bit-banged serial code examples?
Posted: Tue May 18, 2021 11:19 am
by plasmo
Bitbang serial receive is more difficult than bitbang serial transmit. CRC65 has a hybrid solution where the serial receiver is in hardware (implemented in CPLD logic) but bitbang the transmitter to save CPLD resources. The code for bitbang transmitter is here,
viewtopic.php?f=6&t=6440&hilit=Bitbang+ ... =15#p81149
Bill
Re: 6502 bit-banged serial code examples?
Posted: Tue Jun 01, 2021 9:21 am
by pzembrod
pagetable.com has some of the imho best commented C64 Kernal listings where you can find both:
Synchronous bit-banged serial: The serial IEC send (CIOUT) and receive (ACPTR) routines:
CIOUT:
https://www.pagetable.com/c64ref/c64disasm/#EDDD
ACPTR:
https://www.pagetable.com/c64ref/c64disasm/#EE13
Asynchronous bit-banged serial: The RS232 code, hidden within the BASIN and BASOUT routines:
Output to RS232:
https://www.pagetable.com/c64ref/c64disasm/#F208
Input from RS232:
https://www.pagetable.com/c64ref/c64disasm/#F1B8
I find the RS232 code harder to understand (in fact, I really don't understand it) as it uses CIA-2 timer based NMIs.
Re: 6502 bit-banged serial code examples?
Posted: Tue Jun 01, 2021 3:11 pm
by 8BIT
I did the software for Lee Hart's "6502 Badge". That used the IRQ pin as the serial receive. Output was created by storing an 8 bit write to the EPROM area in a latch. Bit 7 of that latch was the serial TX.
The software used cycle counting to generate a 9600 baud half duplex signal. It included a 128 byte receive buffer to help with xmodem file transfers.
More info can be found here ->
http://sunrise-ev.com/6502.htm
Daryl