6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 5:42 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Mon May 17, 2021 9:06 pm 
Offline
User avatar

Joined: Wed Feb 13, 2013 1:38 pm
Posts: 589
Location: Michigan, USA
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


Top
 Profile  
Reply with quote  
PostPosted: Mon May 17, 2021 9:25 pm 
Online
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
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. :o

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
PostPosted: Mon May 17, 2021 9:48 pm 
Offline

Joined: Thu Mar 10, 2016 4:33 am
Posts: 181
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.


Top
 Profile  
Reply with quote  
PostPosted: Tue May 18, 2021 4:48 am 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
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

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Tue May 18, 2021 7:20 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
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:


Top
 Profile  
Reply with quote  
PostPosted: Tue May 18, 2021 11:19 am 
Offline

Joined: Fri Dec 21, 2018 1:05 am
Posts: 1117
Location: Albuquerque NM USA
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+serial&start=15#p81149
Bill


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 01, 2021 9:21 am 
Offline

Joined: Sat Sep 05, 2020 3:12 pm
Posts: 22
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.


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 01, 2021 3:11 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1748
Location: Sacramento, CA
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

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: