Page 1 of 2

IEC serial output bits

Posted: Sat Jul 10, 2021 11:39 am
by bjonte
I looked for the bits to control IEC devices and I get very confused by the VIA2PCR $912c register. Mapping the VIC seems to mess up the documentation here and I'm not sure how to control the CLK and DATA bits. Programmer's Reference Guide also isn't detailing this enough for me to understand. Both claim three bits each are controlling this somehow. What bits should be used? Is there anything I need to do to setup before I use them, like data direction or disabling shift registers?

Re: IEC serial output bits

Posted: Sat Jul 10, 2021 1:14 pm
by srowe
This is a very good and detailed description of how the serial bus works

https://www.pagetable.com/?p=1135

You also need to familiarize yourself with the relevant parts of the schematic, the input and output are driven independently and the outputs go through an inverter.

The mapping of the lines to the VIAs is is follows

Code: Select all

VIA1PA1		= $9111		; VIA 1 DRA
					; bit	function
					; ---	--------
					;  7	serial ATN out
					;  1	serial DATA in
					;  0	serial CLK in

VIA2PCR		= $912C		; VIA 2 PCR
					; bit	function
					; ---	--------
					; 765	CB2 serial DATA out
					;  4	CB1 serial SRQ in
					; 321	CA2 serial CLK out
You shouldn't need to change the DDR, it is initialized correctly by the KERNAL.

Re: IEC serial output bits

Posted: Sat Jul 10, 2021 1:40 pm
by bjonte
But this states three bits for a single line:

765 CB2 serial DATA out
321 CA2 serial CLK out

Which bit is it or how does it work if three bits are needed to set one output bit?

Re: IEC serial output bits

Posted: Sat Jul 10, 2021 1:49 pm
by srowe
The PCR is described in detail in the 6522 datasheet but the serial routines only ever use the two values

Code: Select all

110  manual output mode, low
111  manual output mode, high

Re: IEC serial output bits

Posted: Sat Jul 10, 2021 3:51 pm
by Mike
The 6522 datasheet, the VIC-20 schematic and a *good* ROM listing are your friends here. PRG and 'Mapping the VIC' at best count as secondary sources.

For what matters, the KERNAL contains several routines that set/reset the clock (CA2) and data (CB2) line outputs:

$EF84 - output CA2 low - clears bit 1 (value: 2) in $912C => 7406 inverter puts high level on serial clock line
$EF8D - output CA2 high - sets bit 1 (value: 2) in $912C => 7406 inverter puts dominant low level on serial clock line

$E4A0 - output CB2 low - clears bit 5 (value: 32) in $912C => 7406 inverter puts high level on serial data line
$E4A9 - output CB2 high - sets bit 5 (value: 32) in $912C => 7406 inverter puts dominant low level on serial data line

The other two bits of CA2 and CB2 in $912C have been initialised to manual output beforehand. This happens in the VIA init routine at $FDF9: $FE10 LDA #$DE/$FE12 STA $912C, which set CA2 = 1 and CB2 = 0.

Next question: what are you up to?

Re: IEC serial output bits

Posted: Sun Jul 11, 2021 10:48 am
by bjonte
srowe wrote: Sat Jul 10, 2021 1:49 pm

Code: Select all

110  manual output mode, low
111  manual output mode, high
Ah, of course! How stupid of me. Thanks!

Re: IEC serial output bits

Posted: Sun Jul 11, 2021 10:52 am
by bjonte
Mike wrote: Sat Jul 10, 2021 3:51 pm Next question: what are you up to?
I'm porting my turbo loader to VIC20 in order to make multiplatform releases.

Re: IEC serial output bits

Posted: Mon Jul 12, 2021 12:31 pm
by Vic20-Ian
bjonte wrote: Sun Jul 11, 2021 10:52 am
Mike wrote: Sat Jul 10, 2021 3:51 pm Next question: what are you up to?
I'm porting my turbo loader to VIC20 in order to make multiplatform releases.
Cool - please enter it in The things we want to see / hear development competition ;-)

Re: IEC serial output bits

Posted: Wed Jul 21, 2021 1:10 am
by bjonte
Vic20-Ian wrote: Mon Jul 12, 2021 12:31 pm Cool - please enter it in The things we want to see / hear development competition ;-)
I though this was some kind of joke I didn't understand until I saw the thread about it! The thing I'm working on now isn't official yet and will be exclusive to the members of the Swedish Commodore club so it doesn't really fit.

Re: IEC serial output bits

Posted: Wed Jul 21, 2021 3:20 am
by Vic20-Ian
Sorry to hear that it will be exclusive to members of another group if it could be useful to other members of the Denial community.

I thought as you were posting about it here and asking for help here that it would be available to Denial members too, hence the invitation to enter it into the competition.

Re: IEC serial output bits

Posted: Wed Jul 21, 2021 6:07 am
by Mike
bjonte wrote:I though this was some kind of joke I didn't understand until I saw the thread about it! The thing I'm working on now isn't official yet and will be exclusive to the members of the Swedish Commodore club so it doesn't really fit.
Just asking you if I understood this correctly: you solicited here for help, got answers and now are not willing to return the favour by letting the community here participate with the result?

Re: IEC serial output bits

Posted: Wed Jul 21, 2021 7:08 am
by Vic20-Ian
Einverstanden.

Re: IEC serial output bits

Posted: Wed Jul 21, 2021 10:21 pm
by Mike
Vic20-Ian wrote:Einverstanden.
I am on my own side regarding this matter.

Re: IEC serial output bits

Posted: Thu Jul 22, 2021 3:36 am
by bjonte
Mike wrote: Wed Jul 21, 2021 6:07 am Just asking you if I understood this correctly: you solicited here for help, got answers and now are not willing to return the favour by letting the community here participate with the result?
I'm afraid I have to confirm that. Not exactly a nice gesture. We will have some exclusive Swedish content for the club members. That said, I'm not only doing exclusive content for the club and not only club content either. You can see my first steps towards a multi platform release at https://csdb.dk/release/?id=202107 (Swedish text).

Re: IEC serial output bits

Posted: Thu Jul 22, 2021 4:09 am
by bjonte
We had a discussion about this today and decided to release it publicly some time after the exclusive access launch for members. I'll tell you what it is when it has been announced.