Apple II , DMA question.

Topics related to older 6502-based hardware and systems including (but not limited to) the MOS Technology KIM-1, Synertek SYM-1, and Rockwell AIM-65.
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Apple II , DMA question.

Post by BigDumbDinosaur »

gregorio wrote:
BigDumbDinosaur wrote:
gregorio wrote:
I will have to figure out how to prevent problems with MVN MVP

What sort of problems are you anticipating?
My simulator executes 65816 instructions in the shortest time of 250ns - longer about 500ns (does not emulate 65816 cycles exactly)
I want to get the fastest possible data transfer speed in DMA 1 byte per 1 6502 cycle, so if I send data to Apple2 RAM memory, then every few bytes I will have to perform one 6502 processor cycle to refresh its registers.

E.g. for 10us every 10 MVN or MVP instructions I will have to let the 6502 execute 1 cycle.
How do you plan to halt the 6502 while the simulated 65C816 is processing?
x86?  We ain't got no x86.  We don't NEED no stinking x86!
gregorio
Posts: 77
Joined: 07 Feb 2023

Re: Apple II , DMA question.

Post by gregorio »

My Algorithm for DMA acces:
Only MVN and MVP codes can leave DMA LOW.
all DMA changes only in PHI_0 state
Except for first MVN or MVP and appleRAMI/O acces every MVP or MVN will be start in PHI_0 state.
Executing MVN or MVP :
1. check if AppleRAM or AppleI/O access needed
If not, execute MVN or MVP, go to 8
2. if DMA=LOW, go to 8
3. wait for PHI_1
3. wait for PHI_0
4. set DMA to LOW
5 set the DMAcounter to number of safe cycles.
6 wait PHI_1
7.DMAcounter-1
8.execute MVN or MVP
9.IF DMAcounter=0 or Last MVN or Last MVP then DMA-High
10 Next Opcode.

For interrupts, there are two possible solutions.
1. Treat multiple MVNs as one instruction.
2. Interrupt ends the DMA cycle
Last edited by gregorio on Wed Mar 12, 2025 11:51 am, edited 1 time in total.
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: Apple II , DMA question.

Post by drogon »

BigDumbDinosaur wrote:
How do you plan to halt the 6502 while the simulated 65C816 is processing?
Pulling the DMA pin on the Apple II peripheral connector halts the clock into the 6502. It also tristates the Address bus from the 6502s point of view - I'm not 100% sure about the data bus - my understanding is that the video clocks are still running so you can access RAM on the same half of the clock that the 6502 would normally access it, so single cycle writes (or reads) ought to be possible.

Just don't keep it halted for more time than you feel is prudent to preserve the internal state of the NMOS 6502...

-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
J64C
Posts: 239
Joined: 11 Jul 2021

Re: Apple II , DMA question.

Post by J64C »

gregorio wrote:
In AppleII there is DMA access to RAM. It consists of stopping the 6502 clock. I have a question. For how long can you safely stop the 6502 clock in the LOW state in the MOS version?
40 microseconds.

https://www.savagetaylor.com/TIL/TIL00106.pdf
User avatar
BigDumbDinosaur
Posts: 9425
Joined: 28 May 2009
Location: Midwestern USA (JB Pritzker’s dystopia)
Contact:

Re: Apple II , DMA question.

Post by BigDumbDinosaur »

J64C wrote:
gregorio wrote:
In AppleII there is DMA access to RAM. It consists of stopping the 6502 clock. I have a question. For how long can you safely stop the 6502 clock in the LOW state in the MOS version?
40 microseconds.

https://www.savagetaylor.com/TIL/TIL00106.pdf

That’s likely a pretty conservative value, but no point in trying to determine at what point the 6502’s registers will experience amnesia.

More concerning is the required timing for manipulating the DMA input.  Its state has to be changed on the fall of the clock, but the above document doesn’t indicate how much timing leeway exists after Ø2 goes low.
x86?  We ain't got no x86.  We don't NEED no stinking x86!
User avatar
BigEd
Posts: 11463
Joined: 11 Dec 2008
Location: England
Contact:

Re: Apple II , DMA question.

Post by BigEd »

Very interesting to see a definite number, from Apple no less, who would have had reputational and support cost reasons to be sure it's on the safe side in all circumstances.
gregorio
Posts: 77
Joined: 07 Feb 2023

Re: Apple II , DMA question.

Post by gregorio »

Thanks J64C
It looks like I can send e.g. one screen line at a time.
Uncle Warthog
Posts: 14
Joined: 24 Oct 2017

Re: Apple II , DMA question.

Post by Uncle Warthog »

BigDumbDinosaur wrote:
No sir, the 65C816 in the IIGS is not static and as is the case with all 65Cxx MPUs, the clock can only be safely halted on the high phase.  The IIGS went out of production about a year before the release of the static-core 816.
You're absolutely right and I'd forgotten that. I stand/sit corrected, sir.
Post Reply