| 1 |
// ---------------------------------------------------------------------------- |
| 2 |
// ATMEL Microcontroller Software Support - ROUSSET - |
| 3 |
// ---------------------------------------------------------------------------- |
| 4 |
// DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR |
| 5 |
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 6 |
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE |
| 7 |
// DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 8 |
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 9 |
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
| 10 |
// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 11 |
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 12 |
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
| 13 |
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 14 |
// ---------------------------------------------------------------------------- |
| 15 |
// File Name : SAM7_RAM.mac |
| 16 |
// Object : Generic Macro File for IAR |
| 17 |
// 1.0 17/Aug/05 FBr : Creation |
| 18 |
// ---------------------------------------------------------------------------- |
| 19 |
|
| 20 |
/********************************************************************* |
| 21 |
* |
| 22 |
* _MapRAMAt0() |
| 23 |
* |
| 24 |
* Function description |
| 25 |
* Maps RAM at 0. |
| 26 |
*/ |
| 27 |
_MapRAMAt0(){ |
| 28 |
__message "Changing mapping: RAM mapped to 0"; |
| 29 |
__writeMemory32(0x00000001,0xFFFFFF00,"Memory"); |
| 30 |
} |
| 31 |
|
| 32 |
/********************************************************************* |
| 33 |
* |
| 34 |
* _InitRSTC() |
| 35 |
* |
| 36 |
* Function description |
| 37 |
* Initializes the RSTC (Reset controller). |
| 38 |
* This makes sense since the default is to not allow user resets, which makes it impossible to |
| 39 |
* apply a second RESET via J-Link |
| 40 |
*/ |
| 41 |
_InitRSTC() { |
| 42 |
__writeMemory32(0xA5000001, 0xFFFFFD08,"Memory"); // Allow user reset |
| 43 |
} |
| 44 |
|
| 45 |
/********************************************************************* |
| 46 |
* |
| 47 |
* _InitPLL() |
| 48 |
* Function description |
| 49 |
* Initializes the PMC. |
| 50 |
* 1. Enable the Main Oscillator |
| 51 |
* 2. Configure PLL to 96MHz |
| 52 |
* 3. Switch Master Clock (MCK) on PLL/2 = 48MHz |
| 53 |
*/ |
| 54 |
_InitPLL() { |
| 55 |
|
| 56 |
__message "Set Main Oscillator"; |
| 57 |
__writeMemory32(0x00004001,0xFFFFFc20,"Memory"); // MOSC |
| 58 |
while( !(__readMemory32(0xFFFFFc68,"Memory") & 0x1) ); |
| 59 |
|
| 60 |
__message "Set PLL to 96MHz"; |
| 61 |
__writeMemory32(0x10483f0e,0xFFFFFc2c,"Memory"); // LOCK |
| 62 |
while( !(__readMemory32(0xFFFFFc68,"Memory") & 0x4) ); |
| 63 |
|
| 64 |
__message "Set Master Clock to 48MHz"; |
| 65 |
__writeMemory32(0x00000004,0xFFFFFc30,"Memory"); // MCKRDY |
| 66 |
while( !(__readMemory32(0xFFFFFc68,"Memory") & 0x8) ); |
| 67 |
__writeMemory32(0x00000007,0xFFFFFc30,"Memory"); // MCKRDY |
| 68 |
while( !(__readMemory32(0xFFFFFc68,"Memory") & 0x8) ); |
| 69 |
} |
| 70 |
|
| 71 |
/********************************************************************* |
| 72 |
* |
| 73 |
* execUserReset() : JTAG set initially to Full Speed |
| 74 |
*/ |
| 75 |
execUserReset() { |
| 76 |
__message "execUserReset()"; |
| 77 |
__emulatorSpeed(30000); // Set JTAG speed to 30kHz to make a hardware reset |
| 78 |
__hwReset(0); // Hardware Reset: CPU is automatically halted after the reset |
| 79 |
_InitPLL(); // Allow to debug at JTAG Full Speed |
| 80 |
_MapRAMAt0(); // Remap RAM to address 0 |
| 81 |
__emulatorSpeed(0); // Set JTAG speed to full speed |
| 82 |
} |
| 83 |
|
| 84 |
/********************************************************************* |
| 85 |
* |
| 86 |
* execUserPreload() : JTAG set initially to 32kHz |
| 87 |
*/ |
| 88 |
execUserPreload() { |
| 89 |
__message "execUserPreload()"; |
| 90 |
__hwReset(0); // Hardware Reset: CPU is automatically halted after the reset (JTAG is already configured to 32kHz) |
| 91 |
_InitPLL(); // Allow to load Code at JTAG Full Speed |
| 92 |
_MapRAMAt0(); // Remap RAM to address 0 |
| 93 |
_InitRSTC(); // Enable User Reset to allow execUserReset() execution |
| 94 |
} |