User`s manual

Chapter 6: PLL code
; The crystal frequency on the MiniDragon-Plus3 board is 16 MHz so the default bus speed is
; 8 MHz. In order to set the bus speed high than 8 MHz the PLL must be initialized.
;
; You can cut and paste the following code to the beginning of your program.
;
; The math used to set the PLL frequency is:
;
; PLLCLK = CrystalFreq * 2 * (initSYNR+1) / (initREFDV+1)
;
; CrystalFreq = 16 MHz on MiniDragon Plus3 board
; initSYNR = 5, PLL multiplier will be 6
; initREFDV = 3, PLL divisor will be 4
; PLLCLK = 16*2*6/4 = 48MHz
; The bus speed = PLLCLK / 2 = 24 MHz
;
;
start:
; PLL code for 24MHz bus speed from a 4/8/16 crystal
sei
ldx #0
bclr clksel,x,%10000000 ; clear bit 7, clock derived from oscclk
bset pllctl,x, %01000000 ; Turn PLL on, bit 6 =1 PLL on, bit 6=0 PLL off
ldaa #$05 ; 5+1=6 multiplier
staa synr,x
ldaa #$03 ; divisor=3+1=4, 16*2*6 /4 = 48MHz PLL freq, for 16 MHz crystal
; ldaa #$01 ; divisor=1+1=2, 8*2*6 /2 = 48MHz PLL freq, for 8 MHz crystal
; ldaa #$00 ; divisor=0+1=1, 4*2*6 /1 = 48MHz PLL freq, for 4 MHz crystal
staa refdv,x
wait_b3: brclr crgflg,x, %00001000 wait_b3 ; Wait until bit 3 = 1
bset clksel,x, %10000000
32