Sunday 27 March 2022

Commodore PET Datasette Port 2 Problems

This is quite a convoluted one, so please bear with me.

It all starts with a new game for the Future Was 8 bit 499 range, Cheese and Chive. A game by Misfit, in a similar style to their very successful VIC 20 game, Cheese and Onion. (and yes, I was again responsible for the crisp based name for this one)

As with Misfit's previous titles, this one is quite large, so would ideally need a fastloader to reduce loading times. So the designer of the previous fastloaders, Daniel Kahlin came up with a PET fastloader.

It's a really nice fast loader with animation and a tune and a block counter and it loads fast.

That was all very impressive loading from datasette port 1, but ideally it should also support loading from datasette port 2. Since it bypasses the kernal loading routines, it would need code to fast load from a different IO pin.

After persuading the developers of Vice to add support for the second datasette port, Daniel was able to update the fastloader to support loading from port 1 or 2. This was tested and it worked in Vice.

When I tested it on the Mini PET, it worked fine on datasette 1, but not on datasette 2. It started loading, but locked up at block 41, immediately after it played the first notes of the music.

Daniel confirmed that it did work in vice, and suggested I test it on a "real" PET, just to be sure.

On a real PET (a CBM 8032 board which was being tested using the monitor in my 4032 case), it loaded.

BUT, and this is where my head started to hurt. BUT, there was no sound in the game and when reset, there was no power on beep either.

I turned everything off, moved the datasette back to port 1, powered the PET back on and the power on beep was back. I loaded the game from port 1 and that loaded and there was sound again.

And so begins lots and lots of testing of various different combinations or machines and datasettes, trying to work out what was going on here.

It seems the real PET would not make a power on beep if there was a datasette plugged into port 2. I found also that the game sound returned immediately I unplugged the datasette from port 2, and went away when it was reattached. A datasette in port 1 had no effect on the sound.

I went back to the Mini PET, and repeated the tests, and checked. There was a power on beep, and sound was playing in the game, even if there was a datasette in port 2. 

I thought it may be a faulty datasette drive, so I tried another.

And then another.....and another....

The older drives, the two black PET drives, and the beige early VIC20 one seemed to behave differently to the later VIC20 and C64 ones. 

With these drives, the power on beep and the in game sound was not stopped when plugged into port 2. The game still wouldn't load from port 2, but was fine in port 1.

Or at least it did after I replaced the belt on the beige one. That must be the loosest belt I have seen in a cassette drive.

That's better.

The "new" style drives, those from C64's and later VIC20's, all behaved the same as the first drive I had tested. They blocked the sounds from the real PET when plugged into port 2.

I even tried a C16 one with an adapter, that should be representative of the last generation of these drives.

The PET ones were the earliest generation (at least of Commodore drives - there were some off the shelf cassette players adapted for the very early PET 2001s). The black one appears to have come out of a later 2001, it still has the mounting bracket attached - now you know why there were screw holes on the back of the PET drives and even the early VIC20 drives.

So, to recap.

Mini PET (all datasettes):

Port 1 - all drives load

Port 2 - all drives lock up at 041, no loss of sound

CBM 8032 (old datasettes):

Port 1 - all drives load

Port 2 -  all drives lock up at 041, but there is sound

CBM 8032 (new datasettes):

Port 1 - all drives load

Port 2 - game loads but with no sound

So what's the difference? Well, port 1 read input is wired to the CA1 pin of one of the PIA chips. Port 2 read input is wired to the CB1 pin of the VIA. Sound is wired to the CB2 pin of the same VIA chip. It certainly seems to be due to those two pins being on the same chip. 

As an experiment, I tried the MOS 6522 from the 8032 in the Mini PET.

That made the Mini PET behave like the CBM 8032, loading on new datasettes but loss of sound.

I tried a few other 6522 chips, and all the MOS ones behaved like that one. 

I tried a Rockwell R6522, and that behaved like the WDC W65C22N, no loss of sound but lock ups on loading.

So the behaviour did seem to be down to the chips. Checking the datasheets, there are some differences. The output port of the MOS 6522 should be something like other older NMOS chips:

When used as an output, the pin is either pulled high by the P channel FET, or pulled low by the N channel one. When used as an input, both FETs are disabled and the resistor acts as a pullup on the input.

With the WDC part, the pin is driven by a P channel FET via a resistor when used as an output and a different P channel FET and probably a higher value resistor when used as an input. 

One explanation of the problem could be the CB2 pin is being configured as an output, but is also being driven by the datasette drive, causing a lockup at the output of the device. With the WDC part, the resistor stops this from happening.

Driving the CAx and CBx pins is not as simple as a standard output, they are controlled by the PCR (Peripheral Control Register). This single register controls four pins, as follows:

On the PET, CB1 is the input for the cassette 2 read signal, and CB2 drives the speaker.

From this, it looks like CB1 is only being used as an interrupt source, and cannot be set as an output. However, it is used as an output in certain modes of the shift register functionality, such as when a sound is being played.

This is an annotated disassembly of the code that plays the power on beep sound.

This does not set the PCR, but uses the ACR (Auxiliary Control Register) to shift out bits to the CB2 pin repeatedly at a certain frequency to make a beep.

It starts by setting the ACR to 16 (0001 0000), which sets timer 1 to disabled and timer 2 to timed interrupts and "shift out free running at T2 rate".

This mode clocks the bits out of pin CB2, and does not mention CB1. Some of the other modes send the pulse clock out on pin CB1. I presume what is happening here is CB1 is still being set as an output, but not used. This is conflicting with the signal from the datasette drive. 


When playing sound, the datasette 2 read pin changes from an input to an output. There are two issues here.

1) The design of the PET and 6522 means that when you are playing sounds you cannot reliably read from datasette port 2. This is not normally a problem, only with a fastloader that is trying to play sounds whilst loading from datasette port 2.

To get around this, Daniel has disabled the loading sounds on the fastloader when loading from port 2. That has been tested extensively, and all combinations of drive and port and machine now work.

2) Depending on the type of 6522 and the type of datasette, this can cause the loss of sounds as the two outputs conflict.

If you have a Rockwell R6522 or WDC W65C22N (Mini PET, Mini PET 40/80 or Mini PET 40/80D), then this should not be a problem. The output of these chip have resistors in the high side drivers, as do the outputs of the datasettes, so that prevents any lock ups. 

If you have a MOS 6522 (most original PETs), then there is no resistor in the 6522, so if the datasette is pulling low, and the PET is trying to drive high, the transistor in the datasette output will be fighting with the P channel FET in the PET.

The output of the old style datasette is normally high, so the FETs in the 6522 can drive that high or low and there will just be a bit of wasted energy driving against the pullup resistor in the 7414 / 74LS14 output gate (or discrete transistor depending on model).

The new datasette output is normally low, so the transistor in the inverter gate is active and fights against the P channel FET in the 6522. How strong that is depends on the chip. Some have 7414, some 74LS14, and there will be variations for manufacturer to manufacturer and chip to chip. If that is stronger than the P channel FET in the MOS 6522, then the 6522 output rail gets pulled low and the sound stops.

Based on that, I would not advise leaving a datasette drive plugged into port 2 on an original Commodore PET. It does not appear to be healthy for the 6522 or the datasette drive. Old drives may be less of an issue, but either way, I wouldn't do it. The Mini PETs are not affected.


Cheese and Chive is available on cassette from The Future Was 8 bit.

N.B. on the invoice this will shows a C&C as we have had problems with customs impounding orders as they thought "Cheese and Chive" was a foodstuff.

Or if you want a more immediate fix of Cheese and Chive, you can get a Mini PET 40/80D which has the game built into ROM.

This post is an expanded and updated version of a post from my Patreon. If you want advance previews of posts like this and behind the scenes progress on new projects, you can follow along and support me on Patreon: