📄 sam7_flash.mac
字号:
/*********************************************************************
* SEGGER MICROCONTROLLER SYSTEME GmbH *
* Solutions for real time microcontroller applications *
**********************************************************************
* *
* (C) 2004 - 2005 SEGGER Microcontroller Systeme GmbH *
* *
* www.segger.com Support: support@segger.com *
* *
**********************************************************************
----------------------------------------------------------------------
File : SAM7_Flash.mac
Purpose : Setup file for IAR
Feel free to modify this file acc. to your target system.
-------- END-OF-HEADER ---------------------------------------------
*/
__var i;
__var k;
/*********************************************************************
*
* _DisableWatchdog()
*/
_DisableWatchdog() {
__writeMemory32(0x00008000,0xFFFFFD44,"Memory"); // AT91C_BASE_WDTC->WDTC_WDMR= AT91C_SYSC_WDDIS;
}
/*********************************************************************
*
* _MapFlashAt0()
*
* Function description
* Maps Flash at 0.
* This is default after RESET, but it is possible that the application
* already had a chance to run and map RAM to 0.
* So it does not hurt to make sure that Flash is located at 0.
*
* Notes
* (1) Unfortunately, the mapping can not be assigned, but only toggled.
* Therefor we need to check if RAM is at 0 by trying to modify the
* data at addr. 0.
*/
_MapFlashAt0(){
i = __readMemory32(0x00000000,"Memory");
i = i + 1;
__writeMemory32(i, 0x00,"Memory");
k =__readMemory32(0x00000000,"Memory");
if (i == k) {
__message "Changing mapping: Flash remapped to 0";
__writeMemory32(0x00000001,0xFFFFFF00,"Memory");
}
}
/*********************************************************************
*
* _InitAIC()
*/
_InitAIC() {
__writeMemory32(0xFFFFFFFF,0xFFFFF124,"Memory"); // Mask All interrupt pAic->AIC_IDCR = 0xFFFFFFFF;
for (i = 0; i < 8; i++) {
k = __readMemory32(0xFFFFF130,"Memory"); // AT91C_BASE_AIC->AIC_EOICR
}
}
/*********************************************************************
*
* _InitRSTC()
*
* Function description
* Initializes the RSTC (Reset controller).
* This makes sense since the default is to not allow user resets, which makes it impossible to
* apply a second RESET via J-Link
*/
_InitRSTC() {
__writeMemory32(0xA5000001, 0xFFFFFD08,"Memory"); // Allow user reset
}
/*********************************************************************
*
* _InitPLL()
*/
_InitPLL() {
__writeMemory32(0x002f0100,0xFFFFFF60,"Memory"); // Set 1 wait state for flash (2 cycles)
__writeMemory32(0x00000601,0xFFFFFc20,"Memory"); // PLL
__writeMemory32(0x10191c05,0xFFFFFc2c,"Memory"); // PLL
__writeMemory32(0x00000007,0xFFFFFc30,"Memory"); // PLL
}
/*********************************************************************
*
* _Init()
*/
_Init() {
_InitPLL();
__emulatorSpeed(4000000); // Use full JTAG speed
_InitAIC();
_DisableWatchdog();
_InitRSTC();
_MapFlashAt0();
}
/*********************************************************************
*
* execUserReset()
*/
execUserReset() {
__message "execUserReset()";
__emulatorSpeed(30000); // Slow JTAG speed to be on the safe side
__hwReset(0);
_Init();
}
/*********************************************************************
*
* execUserPreload()
*/
execUserPreload() {
__message "execUserPreload()";
_Init();
}
/**************** End of file ***************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -