View Single Post
Old 01 July 2014, 23:43   #141
FrenchShark
FPGAmiga rulez!
FrenchShark's Avatar
 
Join Date: Dec 2007
Location: South of France
Age: 44
Posts: 155
Quote:
Originally Posted by pandy71 View Post
Are You sure? E clock is same for A1000 and for A4000 - seem that 8520 are the same speed...
I did not check the A4000 schematics but CBM/CSG has released a 2 MHz 8520 and the timer.device on A1200/A4000 Kickstart checks 4 different tick frequencies :
* 50 Hz with 700 KHz E clock,
* 60 Hz with 700 KHz E clock,
* 50 Hz with 1400 KHz E clock,
* 60 Hz with 1400 KHz E clock,

I would prefer to be wrong : it would give me less headache for converting my A500 or A2000 to AGA :-)

EDIT : I found the source code of timer.device v39.4, here is the power supply frequency detection routine:

SupplyFreqDetect

;We launch the timer B (frequency = 715,909Hz or 709,379Hz) and wait
;for 1 TOD tick. We guess the TOD's frequency with the number of
;decremented EClock ticks.

; +----- 65535 : Timer B start
; |
; |
; |
; +----- 53603 : 60 Hz tick (EClock = 715909 Hz)
; |
; +- 52476 : Threshold 50Hz/60Hz
; |
; +----- 51347 : 50 Hz tick (EClock = 709379 Hz)
; |
; +- 46509 : Threshold ECS/AGA
; |
; +----- 41671 : 60 Hz tick (EClock = 1431818 Hz) - AGA 8520
; |
; +- 39416 : Threshold 50Hz/60Hz
; |
; +----- 37160 : 50 Hz tick (EClock = 1418758 Hz) - AGA 8520

lea _ciaa,A0 ;Get base address of CIA A.

bclr #CIACRBB_ALARM,ciacrb(A0)
moveq #0,D0
move.b D0,todhi(A0)
move.b D0,todmid(A0)
move.b D0,todlow(A0) ;Clear the TOD clock

moveq #CIACRBF_RUNMODE,D0
move.b D0,ciacrb(A0) ;Activate one-shot mode for timer B

moveq #-1,D0
move.b D0,tblo(A0)
move.b D0,tbhi(A0) ;Load the timer B latch with $FFFF

move.b todlow(A0),D0
.WaitTick1
tst.b tbhi(A0) ;Does timer B work ?
beq.b .CiaAFail ;If not, Guru time !
cmp.b todlow(A0),D0
beq.b .WaitTick1 ;Wait for a TOD tick.

;The timer B starts decrementing from $FFFF.
move.b #CIACRAF_LOAD|CIACRAF_RUNMODE|CIACRAF_START,ciacrb(A0)

move.b todlow(A0),D0
.WaitTick2
tst.b tbhi(A0) ;Does timer B work ?
beq.b .CiaAFail ;If not, Guru time !
cmp.b todlow(A0),D0
beq.b .WaitTick2 ;Wait for another TOD tick.

moveq #CIACRBF_RUNMODE,D0
move.b D0,ciacrb(A0) ;Stop the timer B.

move.b tbhi(A0),D0
lsl.l #8,D0
move.b tblo(A0),D0 ;Read the timer B value.

cmpi.l #52476,D0 ;Timer B >= 52476 ?
bcs.b .Not60Hz ;No, skip the next two lines.
moveq #60,D0 ;Yes, we have a 60Hz tick.
bra.b .StoreTickInfo ;Store the information.
.Not60Hz

cmpi.l #46509,D0 ;Timer B >= 46509 ?
bcs.b .Not50Hz ;No, skip the next two lines.
moveq #50,D0 ;Yes, we have a 50Hz tick.
bra.b .StoreTickInfo ;Store the information.
.Not50Hz

cmpi.l #39416,D0 ;Timer B >= 39416 ?
bcs.b .Not30Hz ;No, skip the next two lines.
moveq #30,D0 ;Yes, we have a 30Hz tick.
bra.b .StoreTickInfo ;Store the information.
.Not30Hz

moveq #25,D0 ;Timer B < 39416 : 25Hz tick.
.StoreTickInfo
move.l #1000000,D1 ;1,000,000 Ás
divu D0,D1 ;Divided by TOD freq = TOD period (in Ás).
move.w D0,tdev_PSupplyFrqHz(A2) ;Store the frequency.
move.w D1,tdev_PSupplyPerMicroSec(A2) ;Store the period.
rts
.CiaAFail
move.l #$15000002,D0 ;Alert number (AN_TMBadSupply).
bra.w DisplayAlert ;Guru time.

Regards,

Frederic

Last edited by FrenchShark; 02 July 2014 at 00:02.
FrenchShark is offline  
AdSense AdSense  
 
Page generated in 0.06246 seconds with 9 queries