cc65 and RS232 User Port Serial

Basic and Machine Language

Moderator: Moderators

Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: cc65 and RS232 User Port Serial

Post by Bobbi »

Let me know if you want help with any aspects of it! One has to imagine that one of the terminal programs had to tackle this issue in the past otherwise things like XModem downloads would have been totally unreliable. It would be a real achievement to have a nice re-usable module that let us work around the kernal issues so we can do cool stuff with serial port Internet :)
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Post by srowe »

I'm not familiar with the C64 ROMs like I am with the VIC. Fortunately there are detailed disassemblies so it's just a matter of getting educated.

Because the VIA is more flexible than the CIA it should be possible to "dumb" them down to work in the way that the C64 code needs.
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: cc65 and RS232 User Port Serial

Post by Bobbi »

More "versatile" surely :)
alterus
Vic 20 Amateur
Posts: 68
Joined: Wed May 13, 2015 4:29 pm
Website: http://bbs.centronian.ca
Location: Victoria BC

Re: cc65 and RS232 User Port Serial

Post by alterus »

I think the ideal solution would be to have a dedicated userport rs232 driver for use in cc65 for the VIC20. I came across one for the C64 that might be a great place to start:

https://github.com/nanoflite/c64-up2400-cc65

Thats a 2400 baud driver and looks very simple to use.
groepaz
Vic 20 Scientist
Posts: 1180
Joined: Wed Aug 25, 2010 5:30 pm

Re: cc65 and RS232 User Port Serial

Post by groepaz »

via more "flexible" than cia? how? :) the VIA just has a bunch of funky modes and settings that are basically useless.... and not being able to use both timers cascaded is a real bummer.

however, on C64 the rs232 stuff is bitbanged, on vic20 apparently the shift register is used - so the code is pretty different
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: cc65 and RS232 User Port Serial

Post by Mike »

groepaz wrote:on vic20 apparently the shift register is used
Erm, no. In the entire VIC-20 KERNAL, there are no references to the shift register in $911A (or $912A for that matter).
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Post by srowe »

groepaz wrote:via more "flexible" than cia? how? :) the VIA just has a bunch of funky modes and settings that are basically useless.... and not being able to use both timers cascaded is a real bummer.
Reading the CIA ICR immediately clears all pending interrupts, with the VIA you can read the IFR as often as you like, the interrupts only clear when you write to the IFR (or clear the interrupt at source). It's probably not an important difference, but I think it's the reason you can get nested NMIs only on the VIC. If that's the case it should just be a matter of disabling all interrupts in the IER early.
however, on C64 the rs232 stuff is bitbanged, on vic20 apparently the shift register is used - so the code is pretty different
No, the VIC bitbangs in pretty much the same way as the C64, using separate timers for Tx and Rx.
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Post by srowe »

alterus wrote:I think the ideal solution would be to have a dedicated userport rs232 driver for use in cc65 for the VIC20. I came across one for the C64 that might be a great place to start:

https://github.com/nanoflite/c64-up2400-cc65

Thats a 2400 baud driver and looks very simple to use.
A clean implementation would be a great idea. While I could code up the KERNAL interfaces serial shifting isn't really my skill area. Getting the timers right for the baud rate (and working both for PAL and NTSC systems) would need someone familiar with doing this.
groepaz
Vic 20 Scientist
Posts: 1180
Joined: Wed Aug 25, 2010 5:30 pm

Re: cc65 and RS232 User Port Serial

Post by groepaz »

No, the VIC bitbangs in pretty much the same way as the C64, using separate timers for Tx and Rx.
really? interesting... all schematics and docs i looked so far suggest its using the shift registers.... what pins on the userport does it use for rs232 then?
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Post by srowe »

groepaz wrote: really? interesting... all schematics and docs i looked so far suggest its using the shift registers.... what pins on the userport does it use for rs232 then?
The userport pins are the same as the C64: N - signal ground, M - Tx, B + C - Rx. The VIA/CIA pinouts map as follows

Code: Select all

I/O pin   VIC   C64
-------   ---   ---
B         CB1   /FLAG
C         PB0   PB0
M         CB2   PA2
groepaz
Vic 20 Scientist
Posts: 1180
Joined: Wed Aug 25, 2010 5:30 pm

Re: cc65 and RS232 User Port Serial

Post by groepaz »

so it is using CB2 afterall.... and then it still does bitbanging (the shiftregister goes to CB2 too!) - interesting. you can perhaps adapt the UP9600 driver for c64 then (which uses the CIA shiftregister)... but other than on c64, the rs232 interface would NOT require a hardware modification to work :) (thinking about it again, it would probably only work half-duplex. damn :))
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
Bobbi
Vic 20 Afficionado
Posts: 355
Joined: Thu Oct 13, 2016 11:35 am
Location: Toronto
Occupation: Programmer

Re: cc65 and RS232 User Port Serial

Post by Bobbi »

I'd settle for reliable 1200 baud operation.

Don't forget about the VIA shift register bug. The original plan on the VIC was to use the shift register for RS-232 but there was a last minute change of plan when the VIA shifting bug was discovered.
groepaz
Vic 20 Scientist
Posts: 1180
Joined: Wed Aug 25, 2010 5:30 pm

Re: cc65 and RS232 User Port Serial

Post by groepaz »

that bug is only relevant with external clocking though, which you wouldnt use here (instead you'd still wait for the startbit by polling - which is also how that UP9600 thing works on c64 iirc).

also...isnt the vic20 even slightly faster than c64? it should be possible to do 2400 then too...
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Post by srowe »

groepaz wrote: also...isnt the vic20 even slightly faster than c64? it should be possible to do 2400 then too...
Looks like the PAL version is:

Code: Select all

         PAL         NTSC
         ---         ----
VIC   1108404 Hz   1022727 Hz
C64    985248 Hz   1022727 Hz
User avatar
srowe
Vic 20 Scientist
Posts: 1325
Joined: Mon Jun 16, 2014 3:19 pm

Re: cc65 and RS232 User Port Serial

Post by srowe »

I'm not sure I agree with Compute!'s assertion that the NMI ISR is significantly different between the VIC and the C64. The changes are mainly because of the VIA vs CIA behaviour that I've mentioned above.

There's a minor difference with handling Rx interrupts at the same time as Tx on the C64. I can only think that the delay of exiting the ISR and re-entering it on the VIC might lose the start of an incoming byte. I'll try coding the Tx handling to do both but I'm doubtful that will fix anything.

There seems to have been multiple C64 ROM versions and the RS-232 code varies between them. I think it's more likely there are other changes I need to pull in.
Post Reply