Login
Back to forumReply to this topicGo to last reply

Posted By

crock
on 2022-09-18
14:59:59
 How to time a disk operation?

Hi all, I would like to find a way to time a disk operation from BASIC. As I recall, TED basic has the same problem as the C64 in that when you read the status channel from the drive, interrupts are suspended and TI/TI$ is not updated.

On the 64 though, the Time of Day clocks on the CIA continue to run, so you can set and read them from basic instead of relying on TI$. The timers on TED however are only 16 bit counters and as they count at ~885khz, are too fast to be useful.

I'm sure there must be something I can use - any ideas?

Rob

Posted By

MMS
on 2022-09-19
15:38:48
 Re: How to time a disk operation?

dear crock,

simply the BASIC is too slow for that operation. On the other hand, there is a rarely used very powerful BASIC command WAIT. Your operation could wait for a certain rasterline instead of TI$ counter.
https://www.lemon64.com/forum/viewtopic.php?t=75929&sid=eadbf70dcb6ea51b5f806d0ad040b475

On c64 it was better than using a non-existing GETKEY command happy

Posted By

Krill
on 2022-09-20
09:20:00
 Re: How to time a disk operation?

"On the 64 though, the Time of Day clocks on the CIA continue to run, so you can set and read them from basic instead of relying on TI$. The timers on TED however are only 16 bit counters and as they count at ~885khz, are too fast to be useful."

Since TED counter 1 has a settable period (while the other two have a fixed 16-bit interval), you can couple them arithmetically.

See this forum topic for a similar application on VIA 6522.

Reading the high-bytes of two timers until they remain the same on a second read should be doable even in slow BASIC.

Posted By

crock
on 2022-09-20
18:36:33
 Re: How to time a disk operation?

"Since TED counter 1 has a settable period (while the other two have a fixed 16-bit interval), you can couple them arithmetically."

Now that is the kind of blue sky thinking I like. Let me ponder that for a while.

Posted By

gerliczer
on 2022-09-21
02:42:51
 Re: How to time a disk operation?

Yes, it is a very cool idea indeed. However, while not knowing anything about KERNAL hardware resource usage during IEC data transfer, I'm afraid TED Timer 1 is not freely available.

Posted By

siz
on 2022-09-21
03:44:23
 Re: How to time a disk operation?

I can't check right now but I'm pretty sure that gerliczer is right and KERNAL IEC bus routines use TED timer #1 for bus timing.

Posted By

Krill
on 2022-09-21
04:04:13
 Re: How to time a disk operation?

I set store watchpoints to $ff00 and $ff01, then loaded a directory and then a file... watchpoints did not trigger. =)

The timers seem to be used for tape operation, though, but for IEC timing, only the usual busy-waits decreasing a register are used.
This would be consistent with KERNALs on other Commodore platforms.

Posted By

Krill
on 2022-09-21
04:17:29
 Re: How to time a disk operation?

And note that reading two timer high-bytes in a loop until they remain the same is only required for high-precision measurements involving reading the low-bytes as well (to counter low-byte wrap in the face of non-atomic 16-bit reads).

By simply reading both high-bytes, their difference yields a low-precision estimation, which could be good enough for your purposes.

BASIC might introduce a delay between both reads, but this should only add a little more to the measurement error.



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon