LisaList2

General Category => Files => Lisa Components => Topic started by: sigma7 on September 26, 2023, 04:50:42 PM

Title: 6522 VIA
Post by: sigma7 on September 26, 2023, 04:50:42 PM
There are two 6522s on each Lisa I/O board and each Dual Parallel Expansion Card.

On the 1/5 I/O Board, they are clocked from the 68000 E clock, which is the CPU clock divided by 10. So when using a 20.37504 MHz oscillator/crystal, the E clock/VIA clock is 0.509376 MHz.

On the 2/10 I/O Board and the Dual Parallel Expansion Card, they are clocked at the CPU clock divided by 4, so when using a 20.37504 MHz oscillator/crystal, the VIA clock is 1.273440 MHz.
Title: Re: 6522 VIA
Post by: jamesdenton on September 28, 2023, 02:34:29 PM
Quote from: sigma7 on September 26, 2023, 04:50:42 PM
On the 2/10 I/O Board and the Dual Parallel Expansion Card, they are clocked at the CPU clock divided by 4, so when using a 20.37504 MHz oscillator/crystal, the VIA clock is 1.273440 MHz.

Does this have any noticeable impact on performance or OS compatibility?

Does the Parallel card in the 1/5 behave similarly to the 2/10?
Title: Re: 6522 VIA
Post by: stepleton on September 28, 2023, 04:50:20 PM
I think it can mean that some ProFile emulators will work on the slower clock but not the faster one.
Title: Re: 6522 VIA
Post by: sigma7 on September 28, 2023, 04:52:19 PM
Quote from: jamesdenton on September 28, 2023, 02:34:29 PM
Quote from: sigma7 on September 26, 2023, 04:50:42 PM
On the 2/10 I/O Board and the Dual Parallel Expansion Card ... the VIA clock is 1.273440 MHz.

Does this have any noticeable impact on performance or OS compatibility?

Does the Parallel card in the 1/5 behave similarly to the 2/10?

Yes, the VIAs on the Dual Parallel card have the same clock frequency regardless of being in a 2/10 or 1/5. It is only the 1/5 I/O Board that is different.

The VIA clock frequency affects the two built-in timers of the VIA (and some other subtle characteristics).

There are a few effects of this:

Title: Re: 6522 VIA
Post by: sigma7 on September 28, 2023, 04:56:19 PM
Quote from: stepleton on September 28, 2023, 04:50:20 PM
I think it can mean that some ProFile emulators will work on the slower clock but not the faster one.
I'm not aware of any ProFile emulators that have that issue... is there one?

IIRC, the Apple /// ProFile interface has the highest performance, so an emulator that works with the Apple /// is probably fine with any Lisa parallel port.
Title: Re: 6522 VIA
Post by: stepleton on September 28, 2023, 09:15:03 PM
Quote from: sigma7 on September 28, 2023, 04:56:19 PM
I'm not aware of any ProFile emulators that have that issue... is there one?

The ArduinoFile emulator warns you about this problem (https://github.com/alexthecat123/ArduinoFile#very-important-warning), for now. Alex may be able to say more... the documentation suggests that it might be fixable in code.
Title: Re: 6522 VIA
Post by: AlexTheCat123 on September 29, 2023, 09:53:32 AM
QuoteThe ArduinoFile emulator warns you about this problem, for now. Alex may be able to say more... the documentation suggests that it might be fixable in code.

Yeah, I was barely able to get the ArduinoFile going on my 2/5 because the strobe pulses from the Lisa are bordering on being too fast for the Arduino to keep up with. Even slight changes to the code would cause it to miss one or two strobe pulses during each command, which obviously invalidates the data being transferred. I've tried getting it going on a 2/10, but the strobe pulses put out by the faster VIAs are just too fast/short for the Arduino and I haven't been able to figure out any ways to get it working. I'm sure that someone could probably optimize things enough to make it work, but I'm certainly not that person!

I'm working on a much improved version of the ArduinoFile right now that uses an ESP32 instead of an Arduino Mega and I'm really hoping that the higher speed of the ESP32 will make things work with the 2/10. I've already done a lot of improvements to the ESP32 version's tester mode (tons of new features and commands, including a full suite of Widget diagnostic commands), but I haven't tried the emulator mode yet. Who knows, it might just work without any modifications to the code, but I'm guessing that there will be at least a few things that need to be changed. It could be a little while before this is ready because I've been super busy with school this semester, but hopefully it won't take too long!
Title: Re: 6522 VIA
Post by: patrick on September 29, 2023, 01:20:38 PM
This was the reason why I chose DMA for the IDEfile. Even the 33 MHz Dallas DS87C320 with 1 cycle per CPU clock phase were too slow to reliably catch the strobe pulse of an Apple III. Now it works with a regular divide-by-12 i8031.
Title: Re: 6522 VIA
Post by: AlexTheCat123 on September 29, 2023, 01:37:14 PM
QuoteThis was the reason why I chose DMA for the IDEfile.

Yeah, I greatly considered going with DMA, but one of my main goals with the ArduinoFile was to make the hardware as simple as possible. Hopefully the ESP32 will be fast enough to handle things without having to resort to DMA hardware. I doubt even the ESP32 would be able to handle the speeds required by an Apple ///, but making it work with the 2/10 and parallel card VIAs seems doable!
Title: Re: 6522 VIA
Post by: sigma7 on September 29, 2023, 01:40:24 PM
Quote from: AlexTheCat123 on September 29, 2023, 09:53:32 AM
the strobe pulses from the Lisa are bordering on being too fast for the Arduino to keep up with. Even slight changes to the code would cause it to miss one or two strobe pulses during each command, which obviously invalidates the data being transferred. I've tried getting it going on a 2/10, but the strobe pulses put out by the faster VIAs are just too fast/short for the Arduino and I haven't been able to figure out any ways to get it working.

If the pulses are too short, then you could latch an edge or stretch them (eg. with a one-shot timer such as 74LS123).

To latch an edge without adding parts, one approach could be to set the pin as an interrupt that is masked and isn't actually serviced (since overhead of an interrupt is significant), and then poll the interrupt status flag to see if it has occurred. If so, clear the interrupt flag and read/write the byte.

If the data rate is too fast, I suppose you'll need to optimize or use a faster processor or switch to a DMA design such as used by Apple's ProFile and Patrick's IDEfile.

The data rate will depend on the operating environment. The DMA design of the ProFile can easily handle the 1 MB/s transfer rate of the Apple ///. The fastest data rates you'll encounter with a Lisa is when using MW+II with an XLerator on a 2/10, but IIRC, this is still slower than 1MB/s. Without an XLerator, I suspect BLU has the fastest transfer rate as uses MOVEP.L to read/write 4 bytes per 68K instruction.

The ProFile drivers in Lisa software vary substantially in data rate. It appears that initial specifications of ProFiles distributed to software developers were either very conservative, missing information, or somehow misunderstood, and the software written was not updated to reflect the capability of the production ProFiles. Some drivers (Xenix I think) adds an intentional delay between bytes in a transfer, others have unoptimized loops that move one byte at a time.
Title: Re: 6522 VIA
Post by: AlexTheCat123 on September 29, 2023, 07:08:00 PM
QuoteTo latch an edge without adding parts, one approach could be to set the pin as an interrupt that is masked and isn't actually serviced (since overhead of an interrupt is significant), and then poll the interrupt status flag to see if it has occurred. If so, clear the interrupt flag and read/write the byte.

Wow, that's an absolutely genius idea! I'll definitely give that a shot! I never considered using an interrupt without an ISR, but I bet that could solve all of my problems here.

QuoteThe fastest data rates you'll encounter with a Lisa is when using MW+II with an XLerator on a 2/10, but IIRC, this is still slower than 1MB/s.

I didn't even consider XLerator compatibility when designing the ArduinoFile, but that's definitely something else that I'm going to need to test!