OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [uIP_Demo_IAR_ARM7/] [resource/] [SAM7_RAM.mac] - Blame information for rev 607

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 583 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_RAM.mac
12
//
13
//  1.0 08/Mar/05 JPP    : Creation
14
//  1.1 23/Mar/05 JPP    : Change Variable name
15
//
16
//  $Revision: 2 $
17
//
18
// ---------------------------------------------------------
19
 
20
__var __mac_i;
21
__var __mac_pt;
22
__var __mac_mem;
23
execUserReset()
24
{
25
     CheckNoRemap();
26
     ini();
27
     AIC();
28
     __message "-------------------------------Set PC Reset ----------------------------------";
29
     __writeMemory32(0x00000000,0xB4,"Register");
30
}
31
 
32
execUserPreload()
33
{
34
//*  __message "-------------------------------Set CPSR  ----------------------------------";
35
     __writeMemory32(0xD3,0x98,"Register");
36
    __writeMemory32(0xffffffff,0xFFFFFC14,"Memory");
37
     PllSetting();
38
 //* Init AIC
39
     AIC();
40
 
41
//*  Set the RAM memory at 0x0020 0000 for code AT 0 flash area
42
     CheckNoRemap();
43
//*  Get the Chip ID (AT91C_DBGU_C1R & AT91C_DBGU_C2R
44
    __mac_i=__readMemory32(0xFFFFF240,"Memory");
45
    __message " ---------------------------------------- Chip ID   0x",__mac_i:%X;
46
    __mac_i=__readMemory32(0xFFFFF244,"Memory");
47
    __message " ---------------------------------------- Extention 0x",__mac_i:%X;
48
    __mac_i=__readMemory32(0xFFFFFF6C,"Memory");
49
    __message " ---------------------------------------- Flash Version 0x",__mac_i:%X;
50
 
51
//*  Watchdog Disable
52
    Watchdog();
53
//*    RG();
54
}
55
//-----------------------------------------------------------------------------
56
// PllSetting
57
//-------------------------------
58
// Set PLL
59
//-----------------------------------------------------------------------------
60
PllSetting()
61
{
62
// -1- Enabling the Main Oscillator:
63
//*#define AT91C_PMC_MOR   ((AT91_REG *)        0xFFFFFC20) // (PMC) Main Oscillator Register
64
//*#define AT91C_PMC_PLLR  ((AT91_REG *)        0xFFFFFC2C) // (PMC) PLL Register
65
//*#define AT91C_PMC_MCKR  ((AT91_REG *)        0xFFFFFC30) // (PMC) Master Clock Register
66
 
67
//*pPMC->PMC_MOR = (( AT91C_CKGR_OSCOUNT & (0x06 <<8) |    //0x0000 0600
68
//                          AT91C_CKGR_MOSCEN ));          //0x0000 0001
69
__writeMemory32(0x00000601,0xFFFFFC20,"Memory");
70
 
71
// -2- Wait
72
// -3- Setting PLL and divider:
73
// - div by 5 Fin = 3,6864 =(18,432 / 5)
74
// - Mul 25+1: Fout =   95,8464 =(3,6864 *26)
75
// for 96 MHz the erroe is 0.16%
76
// Field out NOT USED = 0
77
// PLLCOUNT pll startup time esrtimate at : 0.844 ms
78
// PLLCOUNT 28 = 0.000844 /(1/32768)
79
//       pPMC->PMC_PLLR = ((AT91C_CKGR_DIV & 0x05) |       //0x0000 0005
80
//                         (AT91C_CKGR_PLLCOUNT & (28<<8)) //0x0000 1C00
81
//                         (AT91C_CKGR_MUL & (25<<16)));   //0x0019 0000
82
__writeMemory32(0x00191C05,0xFFFFFC2C,"Memory");
83
// -2- Wait
84
// -5- Selection of Master Clock and Processor Clock
85
// select the PLL clock divided by 2
86
//          pPMC->PMC_MCKR = AT91C_PMC_CSS_PLL_CLK |     //0x0000 0003
87
//                           AT91C_PMC_PRES_CLK_2 ;      //0x0000 0004
88
__writeMemory32(0x00000007,0xFFFFFC30,"Memory");
89
 
90
 
91
   __message "------------------------------- PLL  Enable ----------------------------------------";
92
}
93
 
94
//-----------------------------------------------------------------------------
95
// Watchdog
96
//-------------------------------
97
// Normally, the Watchdog is enable at the reset for load it's preferable to
98
// Disable.
99
//-----------------------------------------------------------------------------
100
Watchdog()
101
{
102
//* Watchdog Disable
103
//      AT91C_BASE_WDTC->WDTC_WDMR= AT91C_WDTC_WDDIS;
104
   __writeMemory32(0x00008000,0xFFFFFD44,"Memory");
105
   __message "------------------------------- Watchdog Disable ----------------------------------------";
106
}
107
 
108
CheckNoRemap()
109
{
110
//* Read the value at 0x0
111
    __mac_i =__readMemory32(0x00000000,"Memory");
112
    __mac_mem = __mac_i;
113
    __mac_i=__mac_i+1;
114
    __writeMemory32(__mac_i,0x00,"Memory");
115
    __mac_pt=__readMemory32(0x00000000,"Memory");
116
 
117
 if (__mac_i == __mac_pt)
118
 {
119
   __message "------------------------------- The Remap is done ----------------------------------------";
120
   __writeMemory32( __mac_mem,0x00000000,"Memory");
121
 
122
 } else {
123
   __message "------------------------------- The Remap is NOT -----------------------------------------";
124
//*   Toggel RESET The remap
125
    __writeMemory32(0x00000001,0xFFFFFF00,"Memory");
126
 }
127
 
128
}
129
 
130
//-----------------------------------------------------------------------------
131
// Reset the Interrupt Controller
132
//-------------------------------
133
// Normally, the code is executed only if a reset has been actually performed.
134
// So, the AIC initialization resumes at setting up the default vectors.
135
//-----------------------------------------------------------------------------
136
AIC()
137
{
138
// Mask All interrupt pAic->AIC_IDCR = 0xFFFFFFFF;
139
    __writeMemory32(0xffffffff,0xFFFFF124,"Memory");
140
    __writeMemory32(0xffffffff,0xFFFFF128,"Memory");
141
// disable peripheral clock  Peripheral Clock Disable Register
142
    __writeMemory32(0xffffffff,0xFFFFFC14,"Memory");
143
 
144
// #define AT91C_TC0_SR    ((AT91_REG *)        0xFFFA0020) // (TC0) Status Register
145
// #define AT91C_TC1_SR    ((AT91_REG *)        0xFFFA0060) // (TC1) Status Register
146
// #define AT91C_TC2_SR    ((AT91_REG *)        0xFFFA00A0) // (TC2) Status Register
147
    __readMemory32(0xFFFA0020,"Memory");
148
    __readMemory32(0xFFFA0060,"Memory");
149
    __readMemory32(0xFFFA00A0,"Memory");
150
    for (__mac_i=0;__mac_i < 8; __mac_i++)
151
    {
152
      // AT91C_BASE_AIC->AIC_EOICR
153
      __mac_pt  =  __readMemory32(0xFFFFF130,"Memory");
154
 
155
    }
156
   __message "------------------------------- AIC 2 INIT ---------------------------------------------";
157
}
158
 
159
ini()
160
{
161
__writeMemory32(0x0,0x00,"Register");
162
__writeMemory32(0x0,0x04,"Register");
163
__writeMemory32(0x0,0x08,"Register");
164
__writeMemory32(0x0,0x0C,"Register");
165
__writeMemory32(0x0,0x10,"Register");
166
__writeMemory32(0x0,0x14,"Register");
167
__writeMemory32(0x0,0x18,"Register");
168
__writeMemory32(0x0,0x1C,"Register");
169
__writeMemory32(0x0,0x20,"Register");
170
__writeMemory32(0x0,0x24,"Register");
171
__writeMemory32(0x0,0x28,"Register");
172
__writeMemory32(0x0,0x2C,"Register");
173
__writeMemory32(0x0,0x30,"Register");
174
__writeMemory32(0x0,0x34,"Register");
175
__writeMemory32(0x0,0x38,"Register");
176
 
177
// Set CPSR
178
__writeMemory32(0x0D3,0x98,"Register");
179
 
180
 
181
}
182
 
183
RG()
184
{
185
 
186
__mac_i =__readMemory32(0x00,"Register");   __message "R00 0x",__mac_i:%X;
187
__mac_i =__readMemory32(0x04,"Register");   __message "R01 0x",__mac_i:%X;
188
__mac_i =__readMemory32(0x08,"Register");   __message "R02 0x",__mac_i:%X;
189
__mac_i =__readMemory32(0x0C,"Register");   __message "R03 0x",__mac_i:%X;
190
__mac_i =__readMemory32(0x10,"Register");   __message "R04 0x",__mac_i:%X;
191
__mac_i =__readMemory32(0x14,"Register");   __message "R05 0x",__mac_i:%X;
192
__mac_i =__readMemory32(0x18,"Register");   __message "R06 0x",__mac_i:%X;
193
__mac_i =__readMemory32(0x1C,"Register");   __message "R07 0x",__mac_i:%X;
194
__mac_i =__readMemory32(0x20,"Register");   __message "R08 0x",__mac_i:%X;
195
__mac_i =__readMemory32(0x24,"Register");   __message "R09 0x",__mac_i:%X;
196
__mac_i =__readMemory32(0x28,"Register");   __message "R10 0x",__mac_i:%X;
197
__mac_i =__readMemory32(0x2C,"Register");   __message "R11 0x",__mac_i:%X;
198
__mac_i =__readMemory32(0x30,"Register");   __message "R12 0x",__mac_i:%X;
199
__mac_i =__readMemory32(0x34,"Register");   __message "R13 0x",__mac_i:%X;
200
__mac_i =__readMemory32(0x38,"Register");   __message "R14 0x",__mac_i:%X;
201
__mac_i =__readMemory32(0x3C,"Register");   __message "R13 SVC 0x",__mac_i:%X;
202
__mac_i =__readMemory32(0x40,"Register");   __message "R14 SVC 0x",__mac_i:%X;
203
__mac_i =__readMemory32(0x44,"Register");   __message "R13 ABT 0x",__mac_i:%X;
204
__mac_i =__readMemory32(0x48,"Register");   __message "R14 ABT 0x",__mac_i:%X;
205
__mac_i =__readMemory32(0x4C,"Register");   __message "R13 UND 0x",__mac_i:%X;
206
__mac_i =__readMemory32(0x50,"Register");   __message "R14 UND 0x",__mac_i:%X;
207
__mac_i =__readMemory32(0x54,"Register");   __message "R13 IRQ 0x",__mac_i:%X;
208
__mac_i =__readMemory32(0x58,"Register");   __message "R14 IRQ 0x",__mac_i:%X;
209
__mac_i =__readMemory32(0x5C,"Register");   __message "R08 FIQ 0x",__mac_i:%X;
210
__mac_i =__readMemory32(0x60,"Register");   __message "R09 FIQ 0x",__mac_i:%X;
211
__mac_i =__readMemory32(0x64,"Register");   __message "R10 FIQ 0x",__mac_i:%X;
212
__mac_i =__readMemory32(0x68,"Register");   __message "R11 FIQ 0x",__mac_i:%X;
213
__mac_i =__readMemory32(0x6C,"Register");   __message "R12 FIQ 0x",__mac_i:%X;
214
__mac_i =__readMemory32(0x70,"Register");   __message "R13 FIQ 0x",__mac_i:%X;
215
__mac_i =__readMemory32(0x74,"Register");   __message "R14 FIQ0x",__mac_i:%X;
216
__mac_i =__readMemory32(0x98,"Register");   __message "CPSR     ",__mac_i:%X;
217
__mac_i =__readMemory32(0x94,"Register");   __message "SPSR     ",__mac_i:%X;
218
__mac_i =__readMemory32(0x9C,"Register");   __message "SPSR ABT ",__mac_i:%X;
219
__mac_i =__readMemory32(0xA0,"Register");   __message "SPSR ABT ",__mac_i:%X;
220
__mac_i =__readMemory32(0xA4,"Register");   __message "SPSR UND ",__mac_i:%X;
221
__mac_i =__readMemory32(0xA8,"Register");   __message "SPSR IRQ ",__mac_i:%X;
222
__mac_i =__readMemory32(0xAC,"Register");   __message "SPSR FIQ ",__mac_i:%X;
223
 
224
__mac_i =__readMemory32(0xB4,"Register");   __message "PC 0x",__mac_i:%X;
225
 
226
}
227
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.