## Atom cassette interface

discussion of games, software, hardware & emulators relating to the Acorn Atom and Acorn System machines.
roland
Posts: 3386
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

### Atom cassette interface

In the design of the new Atom main board I discovered something strange in the Atom cassette interface. Take a look at the technical manual:
A logical 1 signal is represented by a frequency of 2.4 KHz whilst logical 0 is a 1.2 KHz frequency. Each bit, that is 0 or 1, lasts for 3.3 mS giving an operating speed of 300 bits per second. The 2.4 KHz standard is derived from the 4 MHz crystal with a frequency divider chain and it is fed to the peripheral interface and the tape output.
However, if you track this frequency you get:
• 4 MHz is divided by 16 (IC44b)
• This 250kHz is divided by 12 (IC47) which gives 20833 Hz
• That is divided by 8 (IC44a)
So the resulting frequency is 2604 Hz and not 2400 Hz. As long as all Atoms do have this frequency it should not be a problem.

Can anyone with an Atom and a scope please check the frequency of this "2400 Hz" signal (e.g. at pin 13 of the 8255)?
256K + 6502 Inside
MAN WOMAN

hoglet
Posts: 8543
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

### Re: Atom cassette interface

roland wrote: This 250kHz is divided by 12 (IC47) which gives 20833 Hz
I suspect this is actually dividing by 13, which would give 2403Hz. It's loading with 3, then counting until there is a carry out.

Dave

Prime
Posts: 2786
Joined: Sun May 31, 2009 11:52 pm
Contact:

### Re: Atom cassette interface

If this helps, this is the Verilog code from my AtomClone, that generates the tape signal, I have tested this loading ans saving to a real cassette and it was able to exchange data with a real Atom.

Code: Select all

``````
// This divides the 4MHz input clock by 1664, this produces
// an output frequency of 2403KHz, this performs the same function
// as IC44 and IC47 on the original Atom schematic.
// If the input clock is not 4MHz, then the if (Counter==831) will
// need changing.
always @(negedge Reset or posedge CLK4MHZ)
begin
if (Reset==0)
begin
Counter<=0;
PortC4<=0;
end
else
begin
if (Counter==831)
begin
Counter<=0;
PortC4<=~PortC4;
end
else
begin
Counter<=Counter+1;
end
end
end

// Generate the digital Cassette output signal.
assign CASOUT	= ~(~(~PortC4 & PortC1) & PortC0);``````
Cheers.

Phill.

roland
Posts: 3386
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

### Re: Atom cassette interface

Thanks guys,

You made it clear to me. I misunderstood the circuit with the 74LS161.

Thanks Prime for your verilog code. I will try to use the VHDL equivalent for my design. Looks very simple

Greetings,
Roland
256K + 6502 Inside
MAN WOMAN

roland
Posts: 3386
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

### Re: Atom cassette interface

Hello Prime,

I implemented your 2400Hz into my VHDL code, just have to test it.

This is what my code looks like in VHDL:

Code: Select all

``````	process(ClkIn)
variable casClkCnt : casCounter := 0;
begin
if rising_edge(ClkIn) then
-- Clock diverder to 2400 Hz clock signal
-- If the input clock is not 4MHz then the 831 must be adjusted
if casClkCnt = 831 then
casClkOut <= not casClkOut;
casClkCnt := 0;
else
casClkCnt := casClkCnt + 1;
end if;
end if;

end process;
``````
Variable casClkCnt is a range type from 0 to 1000. Later in the code the casClkOut is assigned to an output pin because in my design the generation of the 2400Hz signal and cassette out signals are spread over the two CPLD's.
256K + 6502 Inside
MAN WOMAN

roland
Posts: 3386
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

### Re: Atom cassette interface

It works

I programmed my VHDL into a CPLD and connected 4MHz at the input clock and measured the frequency at my output pin. At first with a small in-ear headphone of my mobile phone and I head a well-known long beep at about 2400 Hz.

Later I tested with the frequency counter program at http://acornatom.nl/atom_nieuws/1983/nr6/19836065.htm and it says 2404 Hz. Maybe by playing with the value of 831 I can fine-tune it to exactly 2400 Hz but I don't think that is necessary.

According to this program the frequency at PC4 of the 8255 is 2403 Hz. So that is also settled then The frequency at PC7 (FS signal from 6847) is exactly 60Hz so for me this proves that the frequency counter program is quite accurate.
256K + 6502 Inside
MAN WOMAN