📄 flash.c
字号:
/*********************************************************************
Author : ADI - Apps www.analog.com/MicroConverter
Date : Sept. 2005
File : Flash.c , RAM.c
Hardware : Applicable to ADuC702x rev H or I silicon
Currently targetting ADuC7026.
Description : This example demonstrate how to place functions in RAM.
The UART is configured, the current PC location printed
to a termainl ( 9600-8-N-1 ), the program then jumps to
the RAM function and prints the current PC location to
the termainl. The example includes a function that has
code written in assembly that allows us access the
Program Counter
Note : The files syscalls.c and serial.c are required.
*********************************************************************/
#include <ADuC7026.h>
#include<stdio.h>
// Function Prototypes
extern void Ram_Function(void);
int getPC (void);
int main(void)
{
register unsigned int PC;
GP1CON = 0x011; // Setup tx & rx pins on P1.0 and P1.1
// Set UART to 9600bps 8-N-1 (CD=0)
COMCON0 = 0x80; // Setting DLAB
COMDIV0 = 0x88;
COMDIV1 = 0x00;
COMCON0 = 0x07; // Clearing DLAB
//Print current program counter address ... currently executing from FLASH!!
printf("This is the main Flash Function.\n");
PC = getPC(); // Getting current locatin of Program Counter (Register R15)
printf("The Current location of the Program Counter is : 0x%08X\n",PC);
Ram_Function();
return 0;
}
int getPC (void) { // Function to return the current location of the Program Counter
int RetVal;
__asm { // __asm attribute defines code as assembly code
MOV R0,LR
STAV R0,R1,RetVal
}
return (RetVal);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -