1 // ---------------------------------------------------------
\r
2 // ATMEL Microcontroller Software Support - ROUSSET -
\r
3 // ---------------------------------------------------------
\r
4 // The software is delivered "AS IS" without warranty or
\r
5 // condition of any kind, either express, implied or
\r
6 // statutory. This includes without limitation any warranty
\r
7 // or condition with respect to merchantability or fitness
\r
8 // for any particular purpose, or against the infringements of
\r
9 // intellectual property rights of others.
\r
10 // ---------------------------------------------------------
\r
11 // File: SAM9XE_SRAM.mac
\r
12 // User setup file for CSPY debugger.
\r
13 // 1.1 08/Aug/06 jpp : Creation
\r
15 // $Revision: 23594 $
\r
17 // ---------------------------------------------------------
\r
21 /*********************************************************************
\r
23 * execUserReset() : JTAG set initially to Full Speed
\r
27 __message "------------------------------ execUserReset ---------------------------------";
\r
28 _MapRAMAt0(); //* Set the RAM memory at 0x00200000 & 0x00000000
\r
29 __PllSetting(); //* Init PLL
\r
30 __PllSetting100MHz();
\r
31 __message "-------------------------------Set PC Reset ----------------------------------";
\r
34 /*********************************************************************
\r
36 * execUserPreload() : JTAG set initially to 32kHz
\r
40 __message "------------------------------ execUserPreload ---------------------------------";
\r
41 __hwReset(0); //* Hardware Reset: CPU is automatically halted after the reset (JTAG is already configured to 32kHz)
\r
42 __writeMemory32(0xD3,0x98,"Register"); //* Set CPSR
\r
43 __PllSetting(); //* Init PLL
\r
44 __PllSetting100MHz();
\r
45 _MapRAMAt0(); //* Set the RAM memory at 0x0020 0000 & 0x0000 0000
\r
46 _InitRSTC(); //* Enable User Reset to allow execUserReset() execution
\r
51 /*********************************************************************
\r
55 * Function description
\r
56 * Initializes the RSTC (Reset controller).
\r
57 * This makes sense since the default is to not allow user resets, which makes it impossible to
\r
58 * apply a second RESET via J-Link
\r
61 __writeMemory32(0xA5000001, 0xFFFFFD08,"Memory"); // Allow user reset
\r
66 /*********************************************************************
\r
69 * Function description
\r
74 // AT91C_MATRIX_MRCR ((AT91_REG *) 0xFFFFEF00) // (MATRIX) Master Remp Control Register
\r
75 __mac_i=__readMemory32(0xFFFFEF00,"Memory");
\r
76 __message "----- AT91C_MATRIX_MRCR : 0x",__mac_i:%X;
\r
78 if ( ((__mac_i & 0x01) == 0) || ((__mac_i & 0x02) == 0)){
\r
79 __message "------------------------------- The Remap is NOT & REMAP ----------------------------";
\r
80 __writeMemory32(0x00000003,0xFFFFEF00,"Memory");
\r
81 __mac_i=__readMemory32(0xFFFFEF00,"Memory");
\r
82 __message "----- AT91C_MATRIX_MRCR : 0x",__mac_i:%X;
\r
84 __message "------------------------------- The Remap is done -----------------------------------";
\r
89 /*********************************************************************
\r
92 * Function description
\r
93 * Initializes the PMC.
\r
94 * 1. Enable the Main Oscillator
\r
100 if ((__readMemory32(0xFFFFFC30,"Memory")&0x3) != 0 ) {
\r
101 //* Disable all PMC interrupt ( $$ JPP)
\r
102 //* AT91C_PMC_IDR ((AT91_REG *) 0xFFFFFC64) //(PMC) Interrupt Disable Register
\r
103 //* pPmc->PMC_IDR = 0xFFFFFFFF;
\r
104 __writeMemory32(0xFFFFFFFF,0xFFFFFC64,"Memory");
\r
105 //* AT91C_PMC_PCDR ((AT91_REG *) 0xFFFFFC14) //(PMC) Peripheral Clock Disable Register
\r
106 __writeMemory32(0xFFFFFFFF,0xFFFFFC14,"Memory");
\r
107 // Disable all clock only Processor clock is enabled.
\r
108 __writeMemory32(0xFFFFFFFE,0xFFFFFC04,"Memory");
\r
110 // AT91C_PMC_MCKR ((AT91_REG *) 0xFFFFFC30) // (PMC) Master Clock Register
\r
111 __writeMemory32(0x00000001,0xFFFFFC30,"Memory");
\r
114 // write reset value to PLLA and PLLB
\r
115 // AT91C_PMC_PLLAR ((AT91_REG *) 0xFFFFFC28) // (PMC) PLL A Register
\r
116 __writeMemory32(0x00003F00,0xFFFFFC28,"Memory");
\r
118 // AT91C_PMC_PLLBR ((AT91_REG *) 0xFFFFFC2C) // (PMC) PLL B Register
\r
119 __writeMemory32(0x00003F00,0xFFFFFC2C,"Memory");
\r
122 __message "------------------------------- PLL Enable -----------------------------------------";
\r
124 __message " ********* Core in SLOW CLOCK mode ********* "; }
\r
128 /*********************************************************************
\r
130 * __PllSetting100MHz()
\r
131 * Function description
\r
132 * Set core at 200 MHz and MCK at 100 MHz
\r
134 __PllSetting100MHz()
\r
137 __message "------------------------------- PLL Set at 100 MHz ----------------------------------";
\r
139 //* pPmc->PMC_MOR = (( AT91C_CKGR_OSCOUNT & (0x40 <<8) | AT91C_CKGR_MOSCEN ));
\r
140 __writeMemory32(0x00004001,0xFFFFFC20,"Memory");
\r
142 // AT91C_PMC_MCKR ((AT91_REG *) 0xFFFFFC30) // (PMC) Master Clock Register
\r
143 __writeMemory32(0x00000001,0xFFFFFC30,"Memory");
\r
145 //* AT91C_BASE_CKGR->CKGR_PLLAR = (AT91C_CKGR_SRCA | ((96 << 16) & AT91C_CKGR_MULA) |
\r
146 // (AT91C_CKGR_PLLACOUNT | (AT91C_CKGR_OUTA_0 | (9);
\r
147 __writeMemory32(0x2060BF09,0xFFFFFC28,"Memory");
\r
149 //* AT91C_BASE_PMC->PMC_MCKR = AT91C_PMC_CSS_PLLA_CLK | AT91C_PMC_PRES_CLK | AT91C_PMC_MDIV_2;;
\r
150 __writeMemory32(0x00000102,0xFFFFFC30,"Memory");
\r