New project: An ACT Apricot F1 "barn find"

Blogs & guides and tales of woo by forum members.
stephen_usher
Posts: 2051
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: New project: An ACT Apricot F1 "barn find"

Post by stephen_usher » Sun Aug 08, 2021 6:05 pm

Oh, and the next project is a biggie... A RAM expansion + Hard disk emulation card.

I've been thinking through the RAM expansion and other than the address decoding and byte access logic it shouldn't be too difficult using Cyrpess Semiconductor CY62167G-45XI 1Mbx16 SDRAM chips.

Seeing as the maximum amount of the chip I'll use directly by the system is 512K I can use other parts for the HD interface RAM addresses. I'll probably have to use either an Arduino or a Raspberry Pi to simulate the odd WD MFM hard disk controller.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 2051
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: New project: An ACT Apricot F1 "barn find"

Post by stephen_usher » Sun Aug 08, 2021 8:12 pm

Hmm. It looks like the ATTiny85, when using its internal 8MHz clock, isn't fast enough in switching the READY signal reliably.

My initial code, which set the output value with every loop varied between 70us and 90us behind the original signal. Only changing the value on a change brought that down to a reliable 70ms but this is still too long as sometimes the machine thinks that the drive has changed/is not ready after switching between drives.

I'm going to switch to using the PLL (16MHz) clock and see if that improves things.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 2051
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: New project: An ACT Apricot F1 "barn find"

Post by stephen_usher » Sun Aug 08, 2021 8:23 pm

That's brought it down to less than 40us.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 2051
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: New project: An ACT Apricot F1 "barn find"

Post by stephen_usher » Sun Aug 08, 2021 8:33 pm

OK, that seems stable now. *crosses fingers*
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 2051
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: New project: An ACT Apricot F1 "barn find"

Post by stephen_usher » Mon Aug 09, 2021 7:37 pm

I've tweaked the start-up code now. Instead of relying upon the FDC seek test and hoping that 14 seconds is enough time to wait I'm sending 80 step pulses before the FDC gets initialised (effectively what the original floppy firmware did on the drive) and then changing the Select-1 pin to being an input. This guarantees that the drive(s) are at track zero before the ROM does its drive detection. It also means that the ATTiny85's pin has gone tri-state on the Select-1 line before the system starts to use it.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 2051
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: New project: An ACT Apricot F1 "barn find"

Post by stephen_usher » Tue Aug 10, 2021 11:37 am

OK, even 35uS is still too slow when the system is switching between reading both disks.

It seems that it's the pin status reading takes this time as if I add a second read (which I will need to do if I'm emulating the DSKCHG functionality) the latency doubles even if I don't make any other changes.

It looks like it's back to the drawing board, at least for the disk change functionality. I can still use the ATTiny85 for the initial seek to track zero though. Hmm.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 2051
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: New project: An ACT Apricot F1 "barn find"

Post by stephen_usher » Tue Aug 10, 2021 5:10 pm

Switching from using the digitalRead() and digitalWrite() library functions to accessing the registers directly has brought down the latency (most of the time) to < 10uS! Yay! There are very intermittent >40uS delays and I don't know why that could be, possibly a rogue interrupt firing?

Anyway, the disk verification program, which hit the problem, now works. Well, it's worked twice anyway!
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 2051
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: New project: An ACT Apricot F1 "barn find"

Post by stephen_usher » Tue Aug 10, 2021 7:56 pm

Changed the DSKCHG version over to using direct register access using macros and that's consistantly 20uS and all the test work, so I think that's this phase done.

Code: Select all

#include <avr/io.h>

#define DRVSELPIN 4
#define DRVRDYPIN 3
#define CTRLRDYPIN 2
#define RESETSTEPPIN 1
#define DSKCHGPIN 0

#define diWrite(pin,value) \
          if (value == 0) { PORTB &= ~(1 << pin); } else { PORTB |= (1 << pin); }

#define diRead(pin) \
          ((PINB & (1 << pin)) != 0)

unsigned int dskchg;

void send_step() {
  digitalWrite(RESETSTEPPIN, HIGH);
  delay(1);
  digitalWrite(RESETSTEPPIN, LOW);
}

void do_stepping()
{
    int i;

    for (i=0; i < 80; i++)
    {
        send_step();
        delay(2);
    }
}
 
void setup() {
// Set up the initial pin I/O states.
  pinMode(DRVSELPIN, OUTPUT);
  pinMode(DRVRDYPIN, INPUT);
  pinMode(CTRLRDYPIN, OUTPUT);
  pinMode(RESETSTEPPIN, OUTPUT);
  pinMode(DSKCHGPIN, INPUT);

// Make sure that the input for selecting disk change mode is pulled high.

  digitalWrite(DSKCHGPIN, HIGH);
  
// Check to see if we are jumpered to be in DSKCHG mode or READY mode

  dskchg = 1 - digitalRead(DSKCHGPIN);
  
// For the time being disable our STEP pin output.
  digitalWrite(RESETSTEPPIN, LOW);

// Initially pull Drive 1 select line low to enable the drive. After 10 seconds we will release it and make it an input.
  digitalWrite(DRVSELPIN, LOW);

  do_stepping();

  pinMode(DRVSELPIN, INPUT);
  digitalWrite(DRVSELPIN, HIGH);
}

void loop() {
  static unsigned int ready_status[2] = {1, 1};
  static unsigned int step_sent[2] = {0, 0};

  unsigned int drive, rdyval, oldval = 0;
  
// Echo the input from the READY line from the floppy drive to the controller READY line.
  while(1)
  {
      drive = 1 - diRead(PORTB4);
      rdyval = diRead(PORTB3);

      if (dskchg == 1)
      {
        if (rdyval == 1)
        {
          if (step_sent[drive] == 0)
          {
            send_step();
            step_sent[drive] = 1;
          }
          ready_status[drive] = 0;
        }
        else
        {
          ready_status[drive] = 1;
          step_sent[drive] = 0;
        }

        rdyval = ready_status[drive];
      }
      
      if (rdyval != oldval)
      {
          oldval = rdyval;
          diWrite(PIN_PB2, rdyval);
      }
  }
}
Happy bunny... (after a bit of retro-brightening today as I was working from home. Rather less orange than is was!)

IMG_1677.jpg
IMG_1677.jpg (64.37 KiB) Viewed 391 times
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 2051
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: New project: An ACT Apricot F1 "barn find"

Post by stephen_usher » Sat Aug 21, 2021 12:48 pm

I've finally started to work on the RAM expansion board properly by creating a KiCAD library entry for the Cyress SRAM chip and populating the initial schematic with 5 74LS245 chips to act as the gateway for the I/O signals.

Seeing as I want this to be the basis for a further expansion to give hard disk functionality I'm designing this so that the memory data and address bus is isolated by transceivers and selectable either by the system bus or the I/O card. There's a way on the system for a memory or I/O card to lock out the CPU and video circuitry from accessing the bus so that side will be easy enough to set up if the I/O card wants to write to the memory, which it will to be buffer space. Similarly, I can lock out the I/O card if the CPU/Video circuitry happens to be accessing the expansion RAM.

I think I'll also put a set of break-out pins for the address and data buses and control signal as headers on the board so I can debug with a logic analyser.
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

stephen_usher
Posts: 2051
Joined: Mon Nov 13, 2017 7:19 pm
Location: Oxford, UK.
Contact:

Re: New project: An ACT Apricot F1 "barn find"

Post by stephen_usher » Sat Aug 21, 2021 4:46 pm

A quick sanity check on the RAM address decoding:

The RAM expansion needs to sit between 0x40000 and 0xbffff for the 256K F1 to take the RAM to 768K.

RAM decode below 512K is relatively easy: LOW_RAM = A18 AND /A19

RAM between 512K and 768K is more difficult. HIGH_RAM = A19 AND ((/A16 AND /A17) OR A18)

Enable RAM if LOW_RAM OR HIGH_RAM

I think that's right isn't it?
Intro retro computers since before they were retro...
ZX81->Spectrum->Memotech MTX->Sinclair QL->520STM->BBC Micro->TT030->PCs & Sun Workstations.
Added code to the MiNT kernel (still there the last time I checked) + put together MiNTOS.
Collection now with added Macs, Amigas, Suns and Acorns.

Post Reply

Return to “MEMBER BLOGS”