1 |
577 |
jeremybenn |
// ---------------------------------------------------------
|
2 |
|
|
// ATMEL Microcontroller Software Support - ROUSSET -
|
3 |
|
|
// ---------------------------------------------------------
|
4 |
|
|
// The software is delivered "AS IS" without warranty or
|
5 |
|
|
// condition of any kind, either express, implied or
|
6 |
|
|
// statutory. This includes without limitation any warranty
|
7 |
|
|
// or condition with respect to merchantability or fitness
|
8 |
|
|
// for any particular purpose, or against the infringements of
|
9 |
|
|
// intellectual property rights of others.
|
10 |
|
|
// ---------------------------------------------------------
|
11 |
|
|
// File: SAM7.mac
|
12 |
|
|
//
|
13 |
|
|
// User setup file for CSPY debugger to simulate interrupt
|
14 |
|
|
// driven Fibonacchi data input.
|
15 |
|
|
// 1.1 16/Jun/04 JPP : Creation
|
16 |
|
|
//
|
17 |
|
|
// $Revision: 2 $
|
18 |
|
|
//
|
19 |
|
|
// ---------------------------------------------------------
|
20 |
|
|
|
21 |
|
|
__var i;
|
22 |
|
|
__var pt;
|
23 |
|
|
|
24 |
|
|
execUserPreload()
|
25 |
|
|
{
|
26 |
|
|
//* Set the RAM memory at 0x0020 0000 for code AT 0 flash area
|
27 |
|
|
CheckRemap();
|
28 |
|
|
//* Get the Chip ID (AT91C_DBGU_C1R & AT91C_DBGU_C2R
|
29 |
|
|
i=__readMemory32(0xFFFFF240,"Memory");
|
30 |
|
|
__message " ---------------------------------------- Chip ID 0x",i:%X;
|
31 |
|
|
i=__readMemory32(0xFFFFF244,"Memory");
|
32 |
|
|
__message " ---------------------------------------- Extention 0x",i:%X;
|
33 |
|
|
//* Get the chip status
|
34 |
|
|
|
35 |
|
|
//* Init AIC
|
36 |
|
|
AIC();
|
37 |
|
|
//* Watchdog Disable
|
38 |
|
|
Watchdog();
|
39 |
|
|
|
40 |
|
|
}
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
//-----------------------------------------------------------------------------
|
44 |
|
|
// Watchdog
|
45 |
|
|
//-------------------------------
|
46 |
|
|
// Normally, the Watchdog is enable at the reset for load it's preferable to
|
47 |
|
|
// Disable.
|
48 |
|
|
//-----------------------------------------------------------------------------
|
49 |
|
|
Watchdog()
|
50 |
|
|
{
|
51 |
|
|
//* Watchdog Disable
|
52 |
|
|
// AT91C_BASE_WDTC->WDTC_WDMR= AT91C_SYSC_WDDIS;
|
53 |
|
|
__writeMemory32(0x00008000,0xFFFFFD44,"Memory");
|
54 |
|
|
__message "------------------------------- Watchdog Disable ----------------------------------------";
|
55 |
|
|
}
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
//-----------------------------------------------------------------------------
|
59 |
|
|
// Check Remap
|
60 |
|
|
//-------------
|
61 |
|
|
//-----------------------------------------------------------------------------
|
62 |
|
|
CheckRemap()
|
63 |
|
|
{
|
64 |
|
|
//* Read the value at 0x0
|
65 |
|
|
i=__readMemory32(0x00000000,"Memory");
|
66 |
|
|
i=i+1;
|
67 |
|
|
__writeMemory32(i,0x00,"Memory");
|
68 |
|
|
pt=__readMemory32(0x00000000,"Memory");
|
69 |
|
|
|
70 |
|
|
if (i == pt)
|
71 |
|
|
{
|
72 |
|
|
__message "------------------------------- The Remap is done ----------------------------------------";
|
73 |
|
|
//* Toggel RESET The remap
|
74 |
|
|
__writeMemory32(0x00000001,0xFFFFFF00,"Memory");
|
75 |
|
|
|
76 |
|
|
} else {
|
77 |
|
|
__message "------------------------------- The Remap is NOT -----------------------------------------";
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
execUserSetup()
|
84 |
|
|
{
|
85 |
|
|
ini();
|
86 |
|
|
__message "-------------------------------Set PC ----------------------------------------";
|
87 |
|
|
__writeMemory32(0x00000000,0xB4,"Register");
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
//-----------------------------------------------------------------------------
|
93 |
|
|
// Reset the Interrupt Controller
|
94 |
|
|
//-------------------------------
|
95 |
|
|
// Normally, the code is executed only if a reset has been actually performed.
|
96 |
|
|
// So, the AIC initialization resumes at setting up the default vectors.
|
97 |
|
|
//-----------------------------------------------------------------------------
|
98 |
|
|
AIC()
|
99 |
|
|
{
|
100 |
|
|
// Mask All interrupt pAic->AIC_IDCR = 0xFFFFFFFF;
|
101 |
|
|
__writeMemory32(0xFFFFFFFF,0xFFFFF124,"Memory");
|
102 |
|
|
|
103 |
|
|
for (i=0;i < 8; i++)
|
104 |
|
|
{
|
105 |
|
|
// AT91C_BASE_AIC->AIC_EOICR
|
106 |
|
|
pt = __readMemory32(0xFFFFF130,"Memory");
|
107 |
|
|
|
108 |
|
|
}
|
109 |
|
|
__message "------------------------------- AIC INIT ---------------------------------------------";
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
ini()
|
113 |
|
|
{
|
114 |
|
|
__writeMemory32(0x0,0x00,"Register");
|
115 |
|
|
__writeMemory32(0x0,0x04,"Register");
|
116 |
|
|
__writeMemory32(0x0,0x08,"Register");
|
117 |
|
|
__writeMemory32(0x0,0x0C,"Register");
|
118 |
|
|
__writeMemory32(0x0,0x10,"Register");
|
119 |
|
|
__writeMemory32(0x0,0x14,"Register");
|
120 |
|
|
__writeMemory32(0x0,0x18,"Register");
|
121 |
|
|
__writeMemory32(0x0,0x1C,"Register");
|
122 |
|
|
__writeMemory32(0x0,0x20,"Register");
|
123 |
|
|
__writeMemory32(0x0,0x24,"Register");
|
124 |
|
|
__writeMemory32(0x0,0x28,"Register");
|
125 |
|
|
__writeMemory32(0x0,0x2C,"Register");
|
126 |
|
|
__writeMemory32(0x0,0x30,"Register");
|
127 |
|
|
__writeMemory32(0x0,0x34,"Register");
|
128 |
|
|
__writeMemory32(0x0,0x38,"Register");
|
129 |
|
|
|
130 |
|
|
// Set CPSR
|
131 |
|
|
__writeMemory32(0x0D3,0x98,"Register");
|
132 |
|
|
|
133 |
|
|
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
RG()
|
137 |
|
|
{
|
138 |
|
|
|
139 |
|
|
i=__readMemory32(0x00,"Register"); __message "R00 0x",i:%X;
|
140 |
|
|
i=__readMemory32(0x04,"Register"); __message "R01 0x",i:%X;
|
141 |
|
|
i=__readMemory32(0x08,"Register"); __message "R02 0x",i:%X;
|
142 |
|
|
i=__readMemory32(0x0C,"Register"); __message "R03 0x",i:%X;
|
143 |
|
|
i=__readMemory32(0x10,"Register"); __message "R04 0x",i:%X;
|
144 |
|
|
i=__readMemory32(0x14,"Register"); __message "R05 0x",i:%X;
|
145 |
|
|
i=__readMemory32(0x18,"Register"); __message "R06 0x",i:%X;
|
146 |
|
|
i=__readMemory32(0x1C,"Register"); __message "R07 0x",i:%X;
|
147 |
|
|
i=__readMemory32(0x20,"Register"); __message "R08 0x",i:%X;
|
148 |
|
|
i=__readMemory32(0x24,"Register"); __message "R09 0x",i:%X;
|
149 |
|
|
i=__readMemory32(0x28,"Register"); __message "R10 0x",i:%X;
|
150 |
|
|
i=__readMemory32(0x2C,"Register"); __message "R11 0x",i:%X;
|
151 |
|
|
i=__readMemory32(0x30,"Register"); __message "R12 0x",i:%X;
|
152 |
|
|
i=__readMemory32(0x34,"Register"); __message "R13 0x",i:%X;
|
153 |
|
|
i=__readMemory32(0x38,"Register"); __message "R14 0x",i:%X;
|
154 |
|
|
i=__readMemory32(0x3C,"Register"); __message "R13 SVC 0x",i:%X;
|
155 |
|
|
i=__readMemory32(0x40,"Register"); __message "R14 SVC 0x",i:%X;
|
156 |
|
|
i=__readMemory32(0x44,"Register"); __message "R13 ABT 0x",i:%X;
|
157 |
|
|
i=__readMemory32(0x48,"Register"); __message "R14 ABT 0x",i:%X;
|
158 |
|
|
i=__readMemory32(0x4C,"Register"); __message "R13 UND 0x",i:%X;
|
159 |
|
|
i=__readMemory32(0x50,"Register"); __message "R14 UND 0x",i:%X;
|
160 |
|
|
i=__readMemory32(0x54,"Register"); __message "R13 IRQ 0x",i:%X;
|
161 |
|
|
i=__readMemory32(0x58,"Register"); __message "R14 IRQ 0x",i:%X;
|
162 |
|
|
i=__readMemory32(0x5C,"Register"); __message "R08 FIQ 0x",i:%X;
|
163 |
|
|
i=__readMemory32(0x60,"Register"); __message "R09 FIQ 0x",i:%X;
|
164 |
|
|
i=__readMemory32(0x64,"Register"); __message "R10 FIQ 0x",i:%X;
|
165 |
|
|
i=__readMemory32(0x68,"Register"); __message "R11 FIQ 0x",i:%X;
|
166 |
|
|
i=__readMemory32(0x6C,"Register"); __message "R12 FIQ 0x",i:%X;
|
167 |
|
|
i=__readMemory32(0x70,"Register"); __message "R13 FIQ 0x",i:%X;
|
168 |
|
|
i=__readMemory32(0x74,"Register"); __message "R14 FIQ0x",i:%X;
|
169 |
|
|
i=__readMemory32(0x98,"Register"); __message "CPSR ",i:%X;
|
170 |
|
|
i=__readMemory32(0x94,"Register"); __message "SPSR ",i:%X;
|
171 |
|
|
i=__readMemory32(0x9C,"Register"); __message "SPSR ABT ",i:%X;
|
172 |
|
|
i=__readMemory32(0xA0,"Register"); __message "SPSR ABT ",i:%X;
|
173 |
|
|
i=__readMemory32(0xA4,"Register"); __message "SPSR UND ",i:%X;
|
174 |
|
|
i=__readMemory32(0xA8,"Register"); __message "SPSR IRQ ",i:%X;
|
175 |
|
|
i=__readMemory32(0xAC,"Register"); __message "SPSR FIQ ",i:%X;
|
176 |
|
|
|
177 |
|
|
i=__readMemory32(0xB4,"Register"); __message "PC 0x",i:%X;
|
178 |
|
|
|
179 |
|
|
}
|
180 |
|
|
|