[comp.sys.amiga.programmer] VPOSR/VHPOSR custom register values

thomas@diku.dk (Thomas Nikolajsen) (06/18/91)

Hello, I tried this question in comp.sys.amiga.hardware, to no avail,
so here we go (it isn't too hardware related anyway).
Please dig out the info, or if there is no answer then say it (Dave).

Background:
Inspired by the timer code in Tomas Rokickis old profiler I want to use
VPOSR/VHPOSR as a timer too (for adding per task time usage to Xoper;
not only per task switch number. For this task I think it is important
not to take up a CIA timer).
As I want the timer to be as accurate as possible and work on all amigas,
(PAL/NTSC, AmigaOS version x.y) I need some info.

Question:
Which values (intervals) does the custom registers VPOSR/VHPOSR take?
Is the resolution 280ns; as given in the hardware manual?
Are there differences for PAL/NTSC machines (in intervals/resolution)?

For short lets call VPOSR/VHPOSR (32b) for VPOSR.l.
It is only the video position I am interested in, lets call it:
vpos_h = VPOSR.l and $ff      ; horizontal
vpos_v = VPOSR.l and $1ff00   ; vertical

In my rather old hardware manual it is just stated that the resolution
is '1/160 of the screen width or 280ns'.
I have made a little program to get emperical results, it gives (PAL):
vpos_h in 0 .. $e2   ( 0 .. 226 )
vpos_v in 0 .. $138  ( 0 .. 312 )
The problem is now that these values doesn't match the 280ns given in
the hardware manual:
313*227*280 ns = 1/50.27 s
Vertical blank frequency if 50 Hz for PAL.

In the 'Introduction to the Amiga 500' which I got when I brought the Amiga,
Appendix F: 'Amiga 500 Schematics', page F-9 contains: Master Clock: X1
Oscillator 28.63836 MHz. Which makes me believe that the resolution is:
1/(28.63836*1000000/8) s = 279.35 ns
which gives:
313*227*275.35 ns = 1/50.38 s
Which brings me to the other questions, is the 280ns value exact?
and is the resolution different for PAL/NTSC machines (what is it?)?

Is VPOSR.l a good timer (stable ..), does it count when video DMA is off
(haven't tried yet)?
I know (from the hardware manual) that it is unusable when a light pen
is connacted.
Which is the correct way to distinguish between PAL/NTSC machines (mode)?
Is it PowerSupplyFrequency(SysBase) or VBlankFrequency(SysBase) or ..?

I don't know much about hardware, I just try to use it (for programming).

When I have gotten this info, I will send off the diffs for xoper to
Werner Gu:nther, so he can include it in his next official version.

thomas@diku.dk, Thomas Nikolajsen, CS. Dept, U. of Copenhagen, Denmark

DXB132@psuvm.psu.edu (06/19/91)

In article <1991Jun18.120731.13523@odin.diku.dk>, thomas@diku.dk (Thomas
Nikolajsen) says:

>Hello, I tried this question in comp.sys.amiga.hardware, to no avail,
>so here we go (it isn't too hardware related anyway).
>Please dig out the info, or if there is no answer then say it (Dave).

>Background:
>Inspired by the timer code in Tomas Rokickis old profiler I want to use
>VPOSR/VHPOSR as a timer too (for adding per task time usage to Xoper;
>not only per task switch number. For this task I think it is important
>not to take up a CIA timer).
>As I want the timer to be as accurate as possible and work on all amigas,
>(PAL/NTSC, AmigaOS version x.y) I need some info.

>Question:
>Which values (intervals) does the custom registers VPOSR/VHPOSR take?
>Is the resolution 280ns; as given in the hardware manual?
>Are there differences for PAL/NTSC machines (in intervals/resolution)?

Yes it's 280ns...well actually 28.63636Mhz divided by 4. The PAL base
clock frequency is slightly slower, but very close. Note that PAL
has 227 color clocks per horizontal line, whereas NTSC uses 227.5
(actually alternated 227..228...227 etc.)

>For short lets call VPOSR/VHPOSR (32b) for VPOSR.l.
>It is only the video position I am interested in, lets call it:
>vpos_h = VPOSR.l and $ff      ; horizontal
>vpos_v = VPOSR.l and $1ff00   ; vertical

>In my rather old hardware manual it is just stated that the resolution
>is '1/160 of the screen width or 280ns'.
>I have made a little program to get emperical results, it gives (PAL):
>vpos_h in 0 .. $e2   ( 0 .. 226 )
>vpos_v in 0 .. $138  ( 0 .. 312 )
>The problem is now that these values doesn't match the 280ns given in
>the hardware manual:
>313*227*280 ns = 1/50.27 s
>Vertical blank frequency if 50 Hz for PAL.

>In the 'Introduction to the Amiga 500' which I got when I brought the Amiga,
>Appendix F: 'Amiga 500 Schematics', page F-9 contains: Master Clock: X1
>Oscillator 28.63836 MHz. Which makes me believe that the resolution is:
>1/(28.63836*1000000/8) s = 279.35 ns
>which gives:
>313*227*275.35 ns = 1/50.38 s
>Which brings me to the other questions, is the 280ns value exact?
>and is the resolution different for PAL/NTSC machines (what is it?)?

Your calculation is right, no it's not exactly 280.


>Is VPOSR.l a good timer (stable ..), does it count when video DMA is off
>(haven't tried yet)?

It is perfect across horizontal blanking intervals. It is not quite
perfect across vertical blanking intervals -- there are a few cycles
where the horizontal and virtical parts don't agree.

>I know (from the hardware manual) that it is unusable when a light pen
>is connacted.
>Which is the correct way to distinguish between PAL/NTSC machines (mode)?
>Is it PowerSupplyFrequency(SysBase) or VBlankFrequency(SysBase) or ..?

For testing whether to use 227 or 227.5, use VBlankFreq. For determining
the base frequency, test PowerSupplyFreq. (At least I think this will
work best...it's really just a guess!)

>I don't know much about hardware, I just try to use it (for programming).

>When I have gotten this info, I will send off the diffs for xoper to
>Werner Gu:nther, so he can include it in his next official version.

>thomas@diku.dk, Thomas Nikolajsen, CS. Dept, U. of Copenhagen, Denmark

Hope this helps a little...

-- Dan Babcock

sschaem@starnet.uucp (Stephan Schaem) (06/19/91)

 About the info Found in SYSBase.You can have 50 in powerfrequncy and
 still have 60hz display... (From experience:-)
 What you should do maybe is time the display to get your basic value.

Blank time can false your timing.Do you base cpu time on a frame basis
or any time lenght? I dont think you will need the HPos.
If you only want to get that for task cpu usage divide frame into time
slot (Vertical lines).Than Count frames,Stop,Start...
Anyway for that you can time one frame so you wont even care if its 50
or 60 and install an interupt server (or else).
Also since its % you can use the HPos vithout timing...
Infact every programer that I know do the above in a way or another.

								Stephan.

vollath@Informatik.TU-Muenchen.DE (Ulrich Vollath) (06/20/91)

In article <91170.042954DXB132@psuvm.psu.edu>, <DXB132@psuvm.psu.edu> writes:
|> In article <1991Jun18.120731.13523@odin.diku.dk>, thomas@diku.dk (Thomas
|> Nikolajsen) says:
|> [.......]
|> >Which is the correct way to distinguish between PAL/NTSC machines (mode)?
|> >Is it PowerSupplyFrequency(SysBase) or VBlankFrequency(SysBase) or ..?
|> 
|> For testing whether to use 227 or 227.5, use VBlankFreq. For determining
|> the base frequency, test PowerSupplyFreq. (At least I think this will
|> work best...it's really just a guess!)
                            ^^^^^^^^^^^^^^^^
Does this work in any case ? I own an US A1000 with a 110V/220V tranformer,
so it runs at 50 hz Power supply, but with 60 hz NTSC video. Is this
taken into account by PowerSupplyFreq?

Ulrich Vollath
-- 

Ulrich Vollath                 email: vollath@lan.informatik.tu-muenchen.de
Munich Institute of Technology voice: 004989/2105-8102 (result: -8099.62992874)

sschaem@starnet.uucp (Stephan Schaem) (06/21/91)

 If your power supply is at 50 and your display 60, powersupplyfreq will
 show 50hz...
 Talking of power supply, can the A3000 powersuply can be simply modify
 to run in europe? (Something like in the A2000).

							Stephan.