qipp
2025-11-07 744722688187eb4991c72464e2bb5e06b244fee7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#include <def21489.h>
 
 
.section/pm     seg_pmco;    // the kernel must reside in a single input_section
.global _initPLL_SDRAM2;
 
//==============================  USER_INIT  ===================================
// This space is provided for the user to insert code. This is only required
// when a system requires a custom configuration for the DSP.  
 
// These External Port and PLL settings are for the ADSP-21469 EZkit.
// Update the settings below to match the requirements for the target board.
//------------------------------------------------------------------------------
_initPLL_SDRAM2:
 
 
 
 
    // Set INDIV bit in PMCTL register
    USTAT1 = dm(PMCTL);
    bit set USTAT1  INDIV;  
    dm(PMCTL) = USTAT1;
 
    // Program PLL multiplier to same value as CLK_CFGx pins/previously programmed value in software……
    dm(PMCTL) = USTAT1;
 
    // Place PLL in bypass mode
    bit set USTAT1  PLLBP;  
    dm(PMCTL) = USTAT1;
 
    // Wait recommended number of cycles
    lcntr=4096, do loopwait1 until lce;
loopwait1:
    nop;
 
    // Bring PLL out of bypass mode by clearing PLLBP bit
    bit clr USTAT1 PLLBP; 
    dm(PMCTL) = USTAT1; 
 
    // Wait for PLL bypass exit
    lcntr=16, do loopwait2 until lce;
loopwait2:
    nop;
 
    USTAT1 = dm(PMCTL);
    // Clear the previous PLL multiplier
    bit clr USTAT1 PLLM63;
    // Clear the INDIV bit
    bit clr USTAT1 INDIV;
    // or set the INDIV bit
    // bit set USTAT1 INDIV;
    dm(PMCTL) = USTAT1;
    
    // Set PMCTL with the desired values
 
// CLKIN= 25 MHz, Multiplier= 16, Divisor= 2, CCLK_SDCLK_RATIO 2.5.
// Fcclk = (CLKIN * 2 * M) / (N * D)
// VCO frequency = 2*fINPUT*PLLM = 2*25*16 = 800 <= fVCOmax (800 MHz)
// M = 1 to 64, N = 2,4,8,16 and D = 1 if INDIV = 0, D = 2 if INDIV = 1
 
 
// Core clock = (25 MHz * 2* 16) /(2 * 1) = 400 MHz
// SDRAM clock = 400 / 2.5 = 160 MHz.
 
    ustat3 = PLLM16|PLLD2|SDCKR2_5|DIVEN;
    dm(PMCTL) = ustat3;
 
    bit set ustat3 PLLBP;    //Setting the PLLBP bit
    bit clr ustat3 DIVEN;    //Clearing the DIVEN bit
    dm(PMCTL) = ustat3;        //Putting the PLL into bypass mode
 
     // Wait for at least 4096 cycles for the pll to lock
    lcntr = 5000, do loopend2 until lce;
loopend2:     nop;
 
    ustat3 = dm(PMCTL);    
    bit clr ustat3 PLLBP;     //Bringing the PLL out of bypass mode
    dm(PMCTL) = ustat3;
    
   lcntr=16, do again until lce; //Wait for around 15 CCLK cycles for output dividers to stabilize
again:  nop;
 
    ustat1 = dm(PMCTL1);
bit set ustat1 FFTACCSEL;
dm(PMCTL1) = ustat1;
nop;
nop;
nop;
nop;    
 
_initPLL_SDRAM2.end:
 
 
//==============================================================================/